MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / run_apidoc

Function run_apidoc

docs/conf.py:94–136  ·  view source on GitHub ↗

generate apidoc See: https://github.com/rtfd/readthedocs.org/issues/1139

(app)

Source from the content-addressed store, hash-verified

92
93
94def run_apidoc(app):
95 """generate apidoc
96
97 See: https://github.com/rtfd/readthedocs.org/issues/1139
98 """
99 import os
100 import shutil
101
102 import sphinx
103 from sphinx.ext import apidoc
104
105 logger = sphinx.util.logging.getLogger(__name__)
106 logger.info("running apidoc")
107 # get correct paths
108 this_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
109 api_folder = os.path.join(this_folder, "api")
110 module_path = os.path.normpath(os.path.join(this_folder, "../"))
111 ignore_paths = ["../scripts", "../conftest.py", "../tests", "../benchmarking"]
112 ignore_paths = [
113 os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
114 ]
115 # functions from these modules are all imported in the __init__.py with __all__
116 for rule in ("block", "core", "inline"):
117 for path in glob(
118 os.path.normpath(
119 os.path.join(this_folder, f"../markdown_it/rules_{rule}/*.py")
120 )
121 ):
122 if os.path.basename(path) not in ("__init__.py", f"state_{rule}.py"):
123 ignore_paths.append(path)
124
125 if os.path.exists(api_folder):
126 shutil.rmtree(api_folder)
127 os.mkdir(api_folder)
128
129 argv = ["-M", "--separate", "-o", api_folder, module_path, *ignore_paths]
130
131 apidoc.OPTIONS.append("ignore-module-all")
132 apidoc.main(argv)
133
134 # we don't use this
135 if os.path.exists(os.path.join(api_folder, "modules.rst")):
136 os.remove(os.path.join(api_folder, "modules.rst"))
137
138
139def setup(app):

Callers

nothing calls this directly

Calls 1

infoMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…