|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from glob import glob |
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
project = "markdown-it-py" |
|
copyright = "2020, executable book project" |
|
author = "executable book project" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extensions = [ |
|
"sphinx.ext.autodoc", |
|
"sphinx.ext.viewcode", |
|
"sphinx.ext.intersphinx", |
|
"myst_parser", |
|
"sphinx_copybutton", |
|
"sphinx_design", |
|
"jupyter_sphinx", |
|
] |
|
|
|
|
|
|
|
|
|
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
|
|
|
nitpicky = True |
|
nitpick_ignore_regex = [ |
|
("py:.*", name) |
|
for name in ( |
|
"_ItemTV", |
|
".*_NodeType", |
|
".*Literal.*", |
|
".*_Result", |
|
"EnvType", |
|
"Path", |
|
"Ellipsis", |
|
) |
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
html_title = "markdown-it-py" |
|
html_theme = "sphinx_book_theme" |
|
html_theme_options = { |
|
"use_edit_page_button": True, |
|
"repository_url": "https://github.com/executablebooks/markdown-it-py", |
|
"repository_branch": "master", |
|
"path_to_docs": "docs", |
|
} |
|
html_static_path = ["_static"] |
|
html_css_files = ["custom.css"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intersphinx_mapping = { |
|
"python": ("https://docs.python.org/3.8", None), |
|
"mdit-py-plugins": ("https://mdit-py-plugins.readthedocs.io/en/latest/", None), |
|
} |
|
|
|
|
|
def run_apidoc(app): |
|
"""generate apidoc |
|
|
|
See: https://github.com/rtfd/readthedocs.org/issues/1139 |
|
""" |
|
import os |
|
import shutil |
|
|
|
import sphinx |
|
from sphinx.ext import apidoc |
|
|
|
logger = sphinx.util.logging.getLogger(__name__) |
|
logger.info("running apidoc") |
|
|
|
this_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) |
|
api_folder = os.path.join(this_folder, "api") |
|
module_path = os.path.normpath(os.path.join(this_folder, "../")) |
|
ignore_paths = ["../scripts", "../conftest.py", "../tests", "../benchmarking"] |
|
ignore_paths = [ |
|
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths |
|
] |
|
|
|
for rule in ("block", "core", "inline"): |
|
for path in glob( |
|
os.path.normpath( |
|
os.path.join(this_folder, f"../markdown_it/rules_{rule}/*.py") |
|
) |
|
): |
|
if os.path.basename(path) not in ("__init__.py", f"state_{rule}.py"): |
|
ignore_paths.append(path) |
|
|
|
if os.path.exists(api_folder): |
|
shutil.rmtree(api_folder) |
|
os.mkdir(api_folder) |
|
|
|
argv = ["-M", "--separate", "-o", api_folder, module_path, *ignore_paths] |
|
|
|
apidoc.OPTIONS.append("ignore-module-all") |
|
apidoc.main(argv) |
|
|
|
|
|
if os.path.exists(os.path.join(api_folder, "modules.rst")): |
|
os.remove(os.path.join(api_folder, "modules.rst")) |
|
|
|
|
|
def setup(app): |
|
"""Add functions to the Sphinx setup.""" |
|
if os.environ.get("SKIP_APIDOC", None) is None: |
|
app.connect("builder-inited", run_apidoc) |
|
|