Skip to content

Commit a22ae92

Browse files
committed
Removed support for documenting languages other than Python
For the reasons why, see #248
1 parent 7b90b43 commit a22ae92

File tree

73 files changed

+34
-4012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+34
-4012
lines changed

README.rst

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@ In contrast to the traditional `Sphinx autodoc <https://www.sphinx-doc.org/en/ma
2828
which requires manual authoring and uses code imports,
2929
AutoAPI finds and generates documentation by parsing source code.
3030

31-
Language Support
32-
----------------
33-
34-
.. warning::
35-
36-
Support for all languages other than Python will be removed in the next major version!
37-
38-
========== ====== ==========================================================
39-
Language Status Parser
40-
========== ====== ==========================================================
41-
Python Stable Custom using `astroid <https://github.com/PyCQA/astroid>`_
42-
Go Alpha `godocjson <https://github.com/readthedocs/godocjson>`_
43-
Javascript Alpha `jsdoc <https://jsdoc.app/>`_
44-
.NET Alpha `docfx <https://dotnet.github.io/docfx/>`_
45-
========== ====== ==========================================================
46-
4731
Getting Started
4832
---------------
4933

@@ -62,29 +46,16 @@ AutoAPI can be installed through pip:
6246
pip install sphinx-autoapi
6347
6448
Next, add and configure AutoAPI in your Sphinx project's `conf.py`.
65-
Other languages may require
66-
`further configuration <https://sphinx-autoapi.readthedocs.io/en/latest/tutorials.html#setting-up-automatic-api-documentation-generation>`_:
6749

6850
.. code-block:: python
6951
7052
extensions.append('autoapi.extension')
7153
72-
autoapi_type = 'python'
7354
autoapi_dirs = ['path/to/source/files', 'src']
7455
75-
Where `autoapi_type` can be one of any of the supported languages:
76-
77-
========== ================
78-
Language ``autoapi_type``
79-
========== ================
80-
Python ``'python'``
81-
Go ``'go'``
82-
Javascript ``'javascript'``
83-
.NET ``'dotnet'``
84-
========== ================
85-
8656
When the documentation is built,
87-
AutoAPI will now generate API documentation into an `autoapi/` directory and add an entry to the documentation in your top level table of contents!
57+
AutoAPI will now generate API documentation into an `autoapi/` directory
58+
and add an entry to the documentation in your top level table of contents!
8859

8960
To configure AutoAPI behaviour further,
9061
see the `Configuration documentation <https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html>`_.

autoapi/backends.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

autoapi/extension.py

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io
66
import os
77
import shutil
8-
import sys
98
from typing import Dict, Tuple
109
import warnings
1110

@@ -17,18 +16,15 @@
1716
from docutils.parsers.rst import directives
1817

1918
from . import documenters
20-
from .backends import (
21-
DEFAULT_FILE_PATTERNS,
22-
DEFAULT_IGNORE_PATTERNS,
23-
LANGUAGE_MAPPERS,
24-
LANGUAGE_REQUIREMENTS,
25-
)
2619
from .directives import AutoapiSummary, NestedParse
2720
from .inheritance_diagrams import AutoapiInheritanceDiagram
21+
from .mappers import PythonSphinxMapper
2822
from .settings import API_ROOT
2923

3024
LOGGER = sphinx.util.logging.getLogger(__name__)
3125

26+
_DEFAULT_FILE_PATTERNS = ["*.py", "*.pyi"]
27+
_DEFAULT_IGNORE_PATTERNS = ["*migrations*"]
3228
_DEFAULT_OPTIONS = [
3329
"members",
3430
"undoc-members",
@@ -66,19 +62,6 @@ def _normalise_autoapi_dirs(autoapi_dirs, srcdir):
6662

6763
def run_autoapi(app): # pylint: disable=too-many-branches
6864
"""Load AutoAPI data from the filesystem."""
69-
if app.config.autoapi_type not in LANGUAGE_MAPPERS:
70-
allowed = ", ".join(f'"{api_type}"' for api_type in sorted(LANGUAGE_MAPPERS))
71-
raise ExtensionError(
72-
f"Invalid autoapi_type setting, following values are allowed: {allowed}"
73-
)
74-
75-
if app.config.autoapi_type != "python":
76-
warnings.warn(
77-
"Support for documenting languages other than Python "
78-
"will be removed in AutoAPI v3.",
79-
RemovedInAutoAPI3Warning,
80-
)
81-
8265
if not app.config.autoapi_dirs:
8366
raise ExtensionError("You must configure an autoapi_dirs setting")
8467

@@ -105,20 +88,6 @@ def run_autoapi(app): # pylint: disable=too-many-branches
10588
)
10689
url_root = os.path.join("/", app.config.autoapi_root)
10790

108-
if not all(
109-
import_name in sys.modules
110-
for _, import_name in LANGUAGE_REQUIREMENTS[app.config.autoapi_type]
111-
):
112-
packages = ", ".join(
113-
f'{import_name} (available as "{pkg_name}" on PyPI)'
114-
for pkg_name, import_name in LANGUAGE_REQUIREMENTS[app.config.autoapi_type]
115-
)
116-
raise ExtensionError(
117-
f"AutoAPI of type `{app.config.autoapi_type}` requires following "
118-
f"packages to be installed and included in extensions list: {packages}"
119-
)
120-
121-
sphinx_mapper = LANGUAGE_MAPPERS[app.config.autoapi_type]
12291
template_dir = app.config.autoapi_template_dir
12392
if template_dir and not os.path.isabs(template_dir):
12493
if not os.path.isdir(template_dir):
@@ -130,17 +99,19 @@ def run_autoapi(app): # pylint: disable=too-many-branches
13099
"relative to where sphinx-build is run\n",
131100
RemovedInAutoAPI3Warning,
132101
)
133-
sphinx_mapper_obj = sphinx_mapper(app, template_dir=template_dir, url_root=url_root)
102+
sphinx_mapper_obj = PythonSphinxMapper(
103+
app, template_dir=template_dir, url_root=url_root
104+
)
134105

135106
if app.config.autoapi_file_patterns:
136107
file_patterns = app.config.autoapi_file_patterns
137108
else:
138-
file_patterns = DEFAULT_FILE_PATTERNS.get(app.config.autoapi_type, [])
109+
file_patterns = _DEFAULT_FILE_PATTERNS
139110

140111
if app.config.autoapi_ignore:
141112
ignore_patterns = app.config.autoapi_ignore
142113
else:
143-
ignore_patterns = DEFAULT_IGNORE_PATTERNS.get(app.config.autoapi_type, [])
114+
ignore_patterns = _DEFAULT_IGNORE_PATTERNS
144115

145116
if ".rst" in app.config.source_suffix:
146117
out_suffix = ".rst"
@@ -171,10 +142,6 @@ def build_finished(app, exception):
171142
)
172143
shutil.rmtree(normalized_root)
173144

174-
sphinx_mapper = LANGUAGE_MAPPERS[app.config.autoapi_type]
175-
if hasattr(sphinx_mapper, "build_finished"):
176-
sphinx_mapper.build_finished(app, exception)
177-
178145

179146
def source_read(app, docname, source): # pylint: disable=unused-argument
180147
# temp_data is cleared after each source file has been processed,
@@ -289,7 +256,6 @@ def setup(app):
289256
app.connect("viewcode-find-source", viewcode_find)
290257
if "viewcode-follow-imported" in app.events.events:
291258
app.connect("viewcode-follow-imported", viewcode_follow_imported)
292-
app.add_config_value("autoapi_type", "python", "html")
293259
app.add_config_value("autoapi_root", API_ROOT, "html")
294260
app.add_config_value("autoapi_ignore", [], "html")
295261
app.add_config_value("autoapi_options", _DEFAULT_OPTIONS, "html")

autoapi/mappers/__init__.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
from .dotnet import DotNetSphinxMapper
21
from .python import PythonSphinxMapper
3-
from .go import GoSphinxMapper
4-
from .javascript import JavaScriptSphinxMapper
52

6-
__all__ = (
7-
"DotNetSphinxMapper",
8-
"PythonSphinxMapper",
9-
"GoSphinxMapper",
10-
"JavaScriptSphinxMapper",
11-
)
3+
__all__ = ("PythonSphinxMapper",)

0 commit comments

Comments
 (0)