Skip to content

Commit

Permalink
Explicitly use the domain for generated directives
Browse files Browse the repository at this point in the history
Closes #292
  • Loading branch information
AWhetter committed Jun 28, 2021
1 parent 26b7d72 commit 2c5c871
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 18 deletions.
18 changes: 12 additions & 6 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ Versions follow `Semantic Versioning <https://semver.org/>`_ (``<major>.<minor>.
v1.8.2 (TBC)
-------------------

Features
^^^^^^^^

* `#292 <https://github.com/readthedocs/sphinx-autoapi/issues/292>`:
Explicitly use the domain for generated directives.

Bug Fixes
^^^^^^^^^

* Fixed error when parsing a class with no constructor.
* `#293 <https://github.com/readthedocs/sphinx-autoapi/issues/293>`:
Fixed failure to build out of source conf.py files.
Configuration values using relative values are now relative to the source directory
instead of relative to the conf.py file.
* `#289 <https://github.com/readthedocs/sphinx-autoapi/issues/289>`: (Python)
Fixed AttributeError using inheritance diagrams on a module with plain imports.


v1.8.1 (2021-04-24)
Expand Down Expand Up @@ -115,12 +127,6 @@ Bug Fixes
Fixed an unnecessary deprecation warning being raised when running
sphinx-build from the same directory as conf.py.
* (Python) Fixed properties documented by Autodoc directives geting documented as methods.
* `#293 <https://github.com/readthedocs/sphinx-autoapi/issues/293>`:
Fixed failure to build out of source conf.py files.
Configuration values using relative values are now relative to the source directory
instead of relative to the conf.py file.
* `#289 <https://github.com/readthedocs/sphinx-autoapi/issues/289>`: (Python)
Fixed AttributeError using inheritance diagrams on a module with plain imports.


V1.5.1 (2020-10-01)
Expand Down
2 changes: 1 addition & 1 deletion autoapi/templates/go/base_member.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% for param in obj.parameters %}
{% set ns.tmpstring = ns.tmpstring ~ argjoin() ~ param.name ~ ' ' ~ param.type %}
{% endfor %}
.. {{ obj.ref_type }}:: {{ obj.name }}({{ ns.tmpstring }})
.. go:{{ obj.ref_type }}:: {{ obj.name }}({{ ns.tmpstring }})
{% else %}
.. go:{{ obj.ref_type }}:: {{ obj.name }}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions autoapi/templates/javascript/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

{% if is_method %}
{# Slice self off #}
.. method:: {{ obj.name.split('.')[-1] }}({{ args[1:]|join(',') }})
.. js:method:: {{ obj.name.split('.')[-1] }}({{ args[1:]|join(',') }})
{% else %}
.. function:: {{ obj.name.split('.')[-1] }}({{ args|join(',') }})
.. js:function:: {{ obj.name.split('.')[-1] }}({{ args|join(',') }})
{% endif %}

{% if obj.docstring %}
Expand Down
2 changes: 1 addition & 1 deletion autoapi/templates/javascript/member.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{# Identention in this file is important #}

.. {{ obj.type }}:: {{ obj.name }}
.. js:{{ obj.type }}:: {{ obj.name }}

{{ obj.docstring|indent(3) }}

Expand Down
2 changes: 1 addition & 1 deletion autoapi/templates/python/class.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if obj.display %}
.. {{ obj.type }}:: {{ obj.short_name }}{% if obj.args %}({{ obj.args }}){% endif %}
.. py:{{ obj.type }}:: {{ obj.short_name }}{% if obj.args %}({{ obj.args }}){% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion autoapi/templates/python/data.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if obj.display %}
.. {{ obj.type }}:: {{ obj.name }}
.. py:{{ obj.type }}:: {{ obj.name }}
{%+ if obj.value is not none or obj.annotation is not none -%}
:annotation:
{%- if obj.annotation %} :{{ obj.annotation }}
Expand Down
2 changes: 1 addition & 1 deletion autoapi/templates/python/function.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if obj.display %}
.. function:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
.. py:function:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions autoapi/templates/python/method.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- if obj.display %}
{% if sphinx_version >= (2, 1) %}
.. method:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
.. py:method:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
Expand All @@ -15,7 +15,7 @@

{% endif %}
{% else %}
.. {{ obj.method_type }}:: {{ obj.short_name }}({{ obj.args }})
.. py:{{ obj.method_type }}:: {{ obj.short_name }}({{ obj.args }})
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.method_type | length) }} {{ obj.short_name }}({{ args }})
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions autoapi/templates/python/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
:orphan:

{% endif %}
:mod:`{{ obj.name }}`
======={{ "=" * obj.name|length }}
:py:mod:`{{ obj.name }}`
=========={{ "=" * obj.name|length }}

.. py:module:: {{ obj.name }}
Expand Down
28 changes: 27 additions & 1 deletion tests/python/test_pyintegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ def built(self, builder):
)


class TestSimpleModuleDifferentPrimaryDomain:
@pytest.fixture(autouse=True, scope="class")
def built(self, builder):
builder(
"pyexample",
warningiserror=True,
confoverrides={
"autoapi_options": [
"members",
"undoc-members",
"private-members",
"special-members",
"imported-members",
],
"primary_domain": "cpp",
"suppress_warnings": ["app"],
},
)

def test_success(self):
pass


class TestSimpleStubModule:
@pytest.fixture(autouse=True, scope="class")
def built(self, builder):
Expand Down Expand Up @@ -725,6 +748,9 @@ class TestComplexPackageParallel:
def built(self, builder):
builder("pypackagecomplex", parallel=2)

def test_success(self):
pass


def test_caching(builder):
mtimes = (0, 0)
Expand Down Expand Up @@ -825,7 +851,7 @@ def test_string_module_attributes(builder):
example_file = example_handle.read()

code_snippet_contents = [
".. data:: code_snippet",
".. py:data:: code_snippet",
" :annotation: = Multiline-String",
"",
" .. raw:: html",
Expand Down

0 comments on commit 2c5c871

Please sign in to comment.