Skip to content

Commit

Permalink
Removed support for documenting languages other than Python
Browse files Browse the repository at this point in the history
For the reasons why, see #248
  • Loading branch information
AWhetter committed Jul 8, 2023
1 parent 7b90b43 commit a22ae92
Show file tree
Hide file tree
Showing 73 changed files with 34 additions and 4,012 deletions.
33 changes: 2 additions & 31 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ In contrast to the traditional `Sphinx autodoc <https://www.sphinx-doc.org/en/ma
which requires manual authoring and uses code imports,
AutoAPI finds and generates documentation by parsing source code.

Language Support
----------------

.. warning::

Support for all languages other than Python will be removed in the next major version!

========== ====== ==========================================================
Language Status Parser
========== ====== ==========================================================
Python Stable Custom using `astroid <https://github.com/PyCQA/astroid>`_
Go Alpha `godocjson <https://github.com/readthedocs/godocjson>`_
Javascript Alpha `jsdoc <https://jsdoc.app/>`_
.NET Alpha `docfx <https://dotnet.github.io/docfx/>`_
========== ====== ==========================================================

Getting Started
---------------

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

.. code-block:: python
extensions.append('autoapi.extension')
autoapi_type = 'python'
autoapi_dirs = ['path/to/source/files', 'src']
Where `autoapi_type` can be one of any of the supported languages:

========== ================
Language ``autoapi_type``
========== ================
Python ``'python'``
Go ``'go'``
Javascript ``'javascript'``
.NET ``'dotnet'``
========== ================

When the documentation is built,
AutoAPI will now generate API documentation into an `autoapi/` directory and add an entry to the documentation in your top level table of contents!
AutoAPI will now generate API documentation into an `autoapi/` directory
and add an entry to the documentation in your top level table of contents!

To configure AutoAPI behaviour further,
see the `Configuration documentation <https://sphinx-autoapi.readthedocs.io/en/latest/reference/config.html>`_.
Expand Down
40 changes: 0 additions & 40 deletions autoapi/backends.py

This file was deleted.

50 changes: 8 additions & 42 deletions autoapi/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io
import os
import shutil
import sys
from typing import Dict, Tuple
import warnings

Expand All @@ -17,18 +16,15 @@
from docutils.parsers.rst import directives

from . import documenters
from .backends import (
DEFAULT_FILE_PATTERNS,
DEFAULT_IGNORE_PATTERNS,
LANGUAGE_MAPPERS,
LANGUAGE_REQUIREMENTS,
)
from .directives import AutoapiSummary, NestedParse
from .inheritance_diagrams import AutoapiInheritanceDiagram
from .mappers import PythonSphinxMapper
from .settings import API_ROOT

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

_DEFAULT_FILE_PATTERNS = ["*.py", "*.pyi"]
_DEFAULT_IGNORE_PATTERNS = ["*migrations*"]
_DEFAULT_OPTIONS = [
"members",
"undoc-members",
Expand Down Expand Up @@ -66,19 +62,6 @@ def _normalise_autoapi_dirs(autoapi_dirs, srcdir):

def run_autoapi(app): # pylint: disable=too-many-branches
"""Load AutoAPI data from the filesystem."""
if app.config.autoapi_type not in LANGUAGE_MAPPERS:
allowed = ", ".join(f'"{api_type}"' for api_type in sorted(LANGUAGE_MAPPERS))
raise ExtensionError(
f"Invalid autoapi_type setting, following values are allowed: {allowed}"
)

if app.config.autoapi_type != "python":
warnings.warn(
"Support for documenting languages other than Python "
"will be removed in AutoAPI v3.",
RemovedInAutoAPI3Warning,
)

if not app.config.autoapi_dirs:
raise ExtensionError("You must configure an autoapi_dirs setting")

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

if not all(
import_name in sys.modules
for _, import_name in LANGUAGE_REQUIREMENTS[app.config.autoapi_type]
):
packages = ", ".join(
f'{import_name} (available as "{pkg_name}" on PyPI)'
for pkg_name, import_name in LANGUAGE_REQUIREMENTS[app.config.autoapi_type]
)
raise ExtensionError(
f"AutoAPI of type `{app.config.autoapi_type}` requires following "
f"packages to be installed and included in extensions list: {packages}"
)

sphinx_mapper = LANGUAGE_MAPPERS[app.config.autoapi_type]
template_dir = app.config.autoapi_template_dir
if template_dir and not os.path.isabs(template_dir):
if not os.path.isdir(template_dir):
Expand All @@ -130,17 +99,19 @@ def run_autoapi(app): # pylint: disable=too-many-branches
"relative to where sphinx-build is run\n",
RemovedInAutoAPI3Warning,
)
sphinx_mapper_obj = sphinx_mapper(app, template_dir=template_dir, url_root=url_root)
sphinx_mapper_obj = PythonSphinxMapper(
app, template_dir=template_dir, url_root=url_root
)

if app.config.autoapi_file_patterns:
file_patterns = app.config.autoapi_file_patterns
else:
file_patterns = DEFAULT_FILE_PATTERNS.get(app.config.autoapi_type, [])
file_patterns = _DEFAULT_FILE_PATTERNS

if app.config.autoapi_ignore:
ignore_patterns = app.config.autoapi_ignore
else:
ignore_patterns = DEFAULT_IGNORE_PATTERNS.get(app.config.autoapi_type, [])
ignore_patterns = _DEFAULT_IGNORE_PATTERNS

if ".rst" in app.config.source_suffix:
out_suffix = ".rst"
Expand Down Expand Up @@ -171,10 +142,6 @@ def build_finished(app, exception):
)
shutil.rmtree(normalized_root)

sphinx_mapper = LANGUAGE_MAPPERS[app.config.autoapi_type]
if hasattr(sphinx_mapper, "build_finished"):
sphinx_mapper.build_finished(app, exception)


def source_read(app, docname, source): # pylint: disable=unused-argument
# temp_data is cleared after each source file has been processed,
Expand Down Expand Up @@ -289,7 +256,6 @@ def setup(app):
app.connect("viewcode-find-source", viewcode_find)
if "viewcode-follow-imported" in app.events.events:
app.connect("viewcode-follow-imported", viewcode_follow_imported)
app.add_config_value("autoapi_type", "python", "html")
app.add_config_value("autoapi_root", API_ROOT, "html")
app.add_config_value("autoapi_ignore", [], "html")
app.add_config_value("autoapi_options", _DEFAULT_OPTIONS, "html")
Expand Down
10 changes: 1 addition & 9 deletions autoapi/mappers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
from .dotnet import DotNetSphinxMapper
from .python import PythonSphinxMapper
from .go import GoSphinxMapper
from .javascript import JavaScriptSphinxMapper

__all__ = (
"DotNetSphinxMapper",
"PythonSphinxMapper",
"GoSphinxMapper",
"JavaScriptSphinxMapper",
)
__all__ = ("PythonSphinxMapper",)
Loading

0 comments on commit a22ae92

Please sign in to comment.