forked from shuup/shuup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_apidoc.py
executable file
·39 lines (30 loc) · 1.07 KB
/
generate_apidoc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# This file is part of Shuup.
#
# Copyright (c) 2012-2021, Shuup Commerce Inc. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
import os
import subprocess
import sys
APIDOC_EXCLUDES = []
def main():
os.chdir(os.path.dirname(__file__))
apidoc_dir = os.path.join("doc", "api")
# Remove all the previous versions
for filename in os.listdir(apidoc_dir):
if filename.endswith(".rst") and filename != "modules.rst":
os.remove(os.path.join(apidoc_dir, filename))
# Generate a list of migration dirs to exclude
migration_excludes = []
for (root, dirnames, filenames) in os.walk("shuup"):
if "migrations" in dirnames:
migration_excludes.append(os.path.join(root, "migrations"))
# Generate new
retcode = subprocess.call(
["sphinx-apidoc", "-o", "doc/api", "shuup"] + APIDOC_EXCLUDES + migration_excludes + sys.argv
)
raise SystemExit(retcode)
if __name__ == "__main__":
main()