|
| 1 | +from datetime import datetime |
| 2 | + |
| 3 | +from recommonmark.parser import CommonMarkParser |
| 4 | +from recommonmark.transform import AutoStructify |
| 5 | + |
| 6 | +# from pystructtype import __version__ |
| 7 | + |
| 8 | + |
| 9 | +# This exists to fix a bug in recommonmark due to a missing function definition |
| 10 | +# https://github.com/readthedocs/recommonmark/issues/177 |
| 11 | +class CustomCommonMarkParser(CommonMarkParser): |
| 12 | + def visit_document(self, node): |
| 13 | + pass |
| 14 | + |
| 15 | + |
| 16 | +# Sphinx Base -------------------------------------------------------------------------- |
| 17 | +# Extensions |
| 18 | +extensions = [ |
| 19 | + # http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html |
| 20 | + "sphinx.ext.autodoc", |
| 21 | + # http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html |
| 22 | + "sphinx.ext.napoleon", |
| 23 | + # http://www.sphinx-doc.org/en/master/usage/extensions/todo.html |
| 24 | + "sphinx.ext.todo", |
| 25 | + # http://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html |
| 26 | + "sphinx.ext.viewcode", |
| 27 | + # https://sphinx-autoapi.readthedocs.io/en/latest/ |
| 28 | + "autoapi.extension", |
| 29 | + # https://github.com/invenia/sphinxcontrib-runcmd |
| 30 | + "sphinxcontrib.runcmd", |
| 31 | +] |
| 32 | + |
| 33 | +# Set initial page name |
| 34 | +master_doc = "index" |
| 35 | + |
| 36 | +# Project settings |
| 37 | +project = "PyStructType" |
| 38 | +year = datetime.now().year |
| 39 | +author = "Fernando Chorney" |
| 40 | +copyright = f"{year}, {author}" |
| 41 | + |
| 42 | +# Short version name |
| 43 | +version = "0.1.0" |
| 44 | + |
| 45 | +# Long version name |
| 46 | +release = version |
| 47 | + |
| 48 | +# HTML Settings |
| 49 | +html_theme = "sphinx_rtd_theme" |
| 50 | +html_last_updated_fmt = "%b %d, %Y" |
| 51 | +html_short_title = f"{project}-{version}" |
| 52 | + |
| 53 | +# Pygments Style Settings |
| 54 | +pygments_style = "monokai" |
| 55 | + |
| 56 | +# Sphinx Extension Autodoc ------------------------------------------------------------- |
| 57 | + |
| 58 | +# Order members by source order |
| 59 | +autodoc_member_order = "bysource" |
| 60 | + |
| 61 | +# Always show members, and member-inheritance by default |
| 62 | +autodoc_default_options = {"members": True, "show-inheritance": True} |
| 63 | + |
| 64 | +# Sphinx Extension Napoleon ------------------------------------------------------------ |
| 65 | + |
| 66 | +# We want to force google style docstrings, so disable numpy style |
| 67 | +napoleon_numpy_docstring = False |
| 68 | + |
| 69 | +# Set output style |
| 70 | +napoleon_use_ivar = True |
| 71 | +napoleon_use_rtype = False |
| 72 | +napoleon_use_param = False |
| 73 | + |
| 74 | +# Sphinx Extension AutoAPI ------------------------------------------------------------- |
| 75 | +autoapi_type = "python" |
| 76 | +autoapi_dirs = ["../src/pystructtype/"] |
| 77 | +autoapi_template_dir = "./autoapi_templates" |
| 78 | +autoapi_root = "autoapi" |
| 79 | +autoapi_add_toctree_entry = False |
| 80 | +autoapi_keep_files = False |
| 81 | + |
| 82 | +# Exclude the autoapi templates in the doc building |
| 83 | +exclude_patterns = ["autoapi_templates"] |
| 84 | + |
| 85 | + |
| 86 | +# Add any Sphinx plugin settings here that don't have global variables exposed. |
| 87 | +def setup(app): |
| 88 | + # App Settings --------------------------------------------------------------------- |
| 89 | + # Set source filetype(s) |
| 90 | + # Allow .rst files along with .md |
| 91 | + app.add_source_suffix(".rst", "restructuredtext") |
| 92 | + app.add_source_suffix(".md", "markdown") |
| 93 | + app.add_source_parser(CustomCommonMarkParser) |
| 94 | + |
| 95 | + # RecommonMark Settings ------------------------------------------------------------ |
| 96 | + # Enable the evaluation of rst directive in .md files |
| 97 | + # https://recommonmark.readthedocs.io/en/latest/auto_structify.html |
| 98 | + app.add_config_value("recommonmark_config", {"enable_eval_rst": True}, True) |
| 99 | + app.add_transform(AutoStructify) |
0 commit comments