|
10 | 10 | # add these directories to sys.path here. If the directory is relative to the
|
11 | 11 | # documentation root, use os.path.abspath to make it absolute, like shown here.
|
12 | 12 | #
|
13 |
| -# import os |
14 |
| -# import sys |
15 |
| -# sys.path.insert(0, os.path.abspath('.')) |
16 |
| - |
| 13 | +import os |
| 14 | +import sys |
17 | 15 | import sphinx_material
|
18 |
| -from recommonmark.transform import AutoStructify |
| 16 | +sys.path.insert(0, os.path.abspath('./API_specification')) |
19 | 17 |
|
20 | 18 | # -- Project information -----------------------------------------------------
|
21 | 19 |
|
22 | 20 | project = 'Python dataframe API standard'
|
23 |
| -copyright = '2020, Consortium for Python Data API Standards' |
| 21 | +copyright = '2022, Consortium for Python Data API Standards' |
24 | 22 | author = 'Consortium for Python Data API Standards'
|
25 | 23 |
|
26 | 24 | # The full version, including alpha/beta/rc tags
|
27 |
| -release = '0.1-dev' |
| 25 | +release = '2022.12-DRAFT' |
28 | 26 |
|
29 | 27 |
|
30 | 28 | # -- General configuration ---------------------------------------------------
|
|
33 | 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
34 | 32 | # ones.
|
35 | 33 | extensions = [
|
36 |
| - 'recommonmark', |
| 34 | + 'myst_parser', |
37 | 35 | 'sphinx.ext.extlinks',
|
38 | 36 | 'sphinx.ext.intersphinx',
|
39 | 37 | 'sphinx.ext.todo',
|
40 | 38 | 'sphinx_markdown_tables',
|
41 | 39 | 'sphinx_copybutton',
|
| 40 | + 'sphinx.ext.autosummary', |
| 41 | + 'sphinx.ext.napoleon', |
| 42 | + 'sphinx.ext.autodoc', |
| 43 | + 'sphinx_math_dollar', |
| 44 | + 'sphinx.ext.mathjax' |
| 45 | +] |
| 46 | + |
| 47 | +autosummary_generate = True |
| 48 | +autodoc_typehints = 'signature' |
| 49 | +add_module_names = False |
| 50 | +napoleon_custom_sections = [('Returns', 'params_style')] |
| 51 | +default_role = 'code' |
| 52 | + |
| 53 | +# Mathjax configuration: |
| 54 | +mathjax3_config = { |
| 55 | + "tex": { |
| 56 | + "inlineMath": [['\\(', '\\)']], |
| 57 | + "displayMath": [["\\[", "\\]"]], |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +# nitpicky = True makes Sphinx warn whenever a cross-reference target can't be |
| 62 | +# found. |
| 63 | +nitpicky = True |
| 64 | +# autodoc wants to make cross-references for every type hint. But a lot of |
| 65 | +# them don't actually refer to anything that we have a document for. |
| 66 | +nitpick_ignore = [ |
| 67 | + ('py:class', 'array'), |
| 68 | + ('py:class', 'dataframe'), |
| 69 | + ('py:class', 'device'), |
| 70 | + ('py:class', 'dtype'), |
| 71 | + ('py:class', 'NestedSequence'), |
| 72 | + ('py:class', 'collections.abc.Sequence'), |
| 73 | + ('py:class', 'PyCapsule'), |
| 74 | + ('py:class', 'enum.Enum'), |
| 75 | + ('py:class', 'ellipsis'), |
42 | 76 | ]
|
| 77 | +# NOTE: this alias handling isn't used yet - added in anticipation of future |
| 78 | +# need based on array API aliases. |
| 79 | +# In dataframe_object.py we have to use aliased names for some types because they |
| 80 | +# would otherwise refer back to method objects of array |
| 81 | +autodoc_type_aliases = { |
| 82 | + 'dataframe': 'dataframe', |
| 83 | + 'Device': 'device', |
| 84 | + 'Dtype': 'dtype', |
| 85 | +} |
| 86 | + |
| 87 | +# Make autosummary show the signatures of functions in the tables using actual |
| 88 | +# Python syntax. There's currently no supported way to do this, so we have to |
| 89 | +# just patch out the function that processes the signatures. See |
| 90 | +# https://github.com/sphinx-doc/sphinx/issues/10053. |
| 91 | +import sphinx.ext.autosummary as autosummary_mod |
| 92 | +if hasattr(autosummary_mod, '_module'): |
| 93 | + # It's a sphinx deprecated module wrapper object |
| 94 | + autosummary_mod = autosummary_mod._module |
| 95 | +autosummary_mod.mangle_signature = lambda sig, max_chars=30: sig |
43 | 96 |
|
44 | 97 | # Add any paths that contain templates here, relative to this directory.
|
45 | 98 | templates_path = ['_templates']
|
|
49 | 102 | # This pattern also affects html_static_path and html_extra_path.
|
50 | 103 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
51 | 104 |
|
| 105 | +# MyST options |
| 106 | +myst_heading_anchors = 3 |
| 107 | +myst_enable_extensions = ["colon_fence"] |
52 | 108 |
|
53 | 109 | # -- Options for HTML output -------------------------------------------------
|
54 | 110 |
|
|
63 | 119 | # Add any paths that contain custom static files (such as style sheets) here,
|
64 | 120 | # relative to this directory. They are copied after the builtin static files,
|
65 | 121 | # so a file named "default.css" will overwrite the builtin "default.css".
|
66 |
| -html_static_path = ['_static'] |
| 122 | +#html_static_path = ['_static'] |
67 | 123 |
|
68 | 124 |
|
69 | 125 | # -- Material theme options (see theme.conf for more information) ------------
|
|
75 | 131 | html_theme_options = {
|
76 | 132 |
|
77 | 133 | # Set the name of the project to appear in the navigation.
|
78 |
| - 'nav_title': 'Python dataframe API standard', |
| 134 | + 'nav_title': f'Python dataframe API standard {release}', |
79 | 135 |
|
80 | 136 | # Set you GA account ID to enable tracking
|
81 | 137 | #'google_analytics_account': 'UA-XXXXX',
|
|
86 | 142 |
|
87 | 143 | # Set the color and the accent color (see
|
88 | 144 | # https://material.io/design/color/the-color-system.html)
|
89 |
| - 'color_primary': 'deep-purple', |
90 |
| - 'color_accent': 'cyan', |
| 145 | + 'color_primary': 'indigo', |
| 146 | + 'color_accent': 'green', |
91 | 147 |
|
92 | 148 | # Set the repo location to get a badge with stats
|
93 | 149 | #'repo_url': 'https://github.com/project/project/',
|
94 | 150 | #'repo_name': 'Project',
|
95 | 151 |
|
96 | 152 | "html_minify": False,
|
97 |
| - "html_prettify": True, |
| 153 | + "html_prettify": False, |
98 | 154 | "css_minify": True,
|
99 | 155 | "logo_icon": "",
|
100 | 156 | "repo_type": "github",
|
|
110 | 166 | 'globaltoc_includehidden': True,
|
111 | 167 |
|
112 | 168 | "nav_links": [
|
113 |
| - {"href": "index", "internal": True, "title": "Array API standard"}, |
| 169 | + {"href": "index", "internal": True, "title": "Dataframe API standard"}, |
114 | 170 | {
|
115 |
| - "href": "https://link-to-consortium-website", |
| 171 | + "href": "https://data-apis.org", |
116 | 172 | "internal": False,
|
117 | 173 | "title": "Consortium for Python Data API Standards",
|
118 | 174 | },
|
119 | 175 | ],
|
120 | 176 | "heroes": {
|
121 |
| - "index": "A common API for array and tensor Python libraries", |
| 177 | + "index": "A common API for dataframe Python libraries", |
122 | 178 | #"customization": "Configuration options to personalize your site.",
|
123 | 179 | },
|
124 | 180 |
|
125 |
| - #"version_dropdown": True, |
126 |
| - #"version_json": "_static/versions.json", |
| 181 | + "version_dropdown": True, |
| 182 | + "version_json": "../versions.json", |
127 | 183 | "table_classes": ["plain"],
|
128 | 184 | }
|
129 | 185 |
|
|
141 | 197 | ),
|
142 | 198 | "durole": ("http://docutils.sourceforge.net/docs/ref/rst/" "roles.html#%s", ""),
|
143 | 199 | "dudir": ("http://docutils.sourceforge.net/docs/ref/rst/" "directives.html#%s", ""),
|
| 200 | + "pypa": ("https://packaging.python.org/%s", ""), |
144 | 201 | }
|
145 | 202 |
|
146 | 203 |
|
147 |
| -# Enable eval_rst in markdown |
| 204 | +def process_signature(app, what, name, obj, options, signature, return_annotation): |
| 205 | + if signature: |
| 206 | + signature = signature.replace("dataframe_api._types.", "") |
| 207 | + if return_annotation: |
| 208 | + return_annotation = return_annotation.replace("dataframe_api._types.", "") |
| 209 | + return signature, return_annotation |
| 210 | + |
148 | 211 | def setup(app):
|
149 |
| - app.add_config_value( |
150 |
| - "recommonmark_config", |
151 |
| - {"enable_math": True, "enable_inline_math": True, "enable_eval_rst": True}, |
152 |
| - True, |
153 |
| - ) |
154 |
| - app.add_transform(AutoStructify) |
155 |
| - app.add_object_type( |
156 |
| - "confval", |
157 |
| - "confval", |
158 |
| - objname="configuration value", |
159 |
| - indextemplate="pair: %s; configuration value", |
160 |
| - ) |
| 212 | + app.connect("autodoc-process-signature", process_signature) |
0 commit comments