Skip to content

Commit 99befd6

Browse files
authored
update external_cpp_references (#257)
- strips the global scope operator from confval's keys - updates doc to use autoclass (obsoletes ignored nitpicky error). - also fixed a typo in task_lists doc
1 parent f21d928 commit 99befd6

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

docs/apidoc/cpp/external_cpp_references.rst

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,25 @@ define the :confval:`external_cpp_references` configuration option:
2020
]
2121
2222
.. literalinclude:: /conf.py
23-
:language: python
24-
:start-after: # BEGIN: sphinx_immaterial.apidoc.cpp.external_cpp_references extension options
25-
:end-before: # END: sphinx_immaterial.apidoc.cpp.external_cpp_references extension options
23+
:language: python
24+
:start-after: # BEGIN: sphinx_immaterial.apidoc.cpp.external_cpp_references extension options
25+
:end-before: # END: sphinx_immaterial.apidoc.cpp.external_cpp_references extension options
2626

2727
.. rst-example::
2828

29-
.. cpp:function:: int ExtractValueFromJson(::nlohmann::json json_value);
29+
.. cpp:function:: int ExtractValueFromJson(::nlohmann::json json_value);
3030

31-
Extracts a value from a JSON object.
31+
Extracts a value from a JSON object.
3232

3333
.. confval:: external_cpp_references
3434

35-
Specifies for each symbol name a dictionary specifying the URL, object type,
36-
and description type:
35+
A dictionary specifying the URL, object type, and descriptive text for each externally
36+
documented symbol name.
3737

38-
.. code-block:: python
39-
40-
class ExternalCppReference(typing.TypedDict):
41-
url: str
42-
object_type: str
43-
desc: str
44-
45-
The :python:`object_type` should be one of the object types defined by the C++ domain:
46-
47-
- :python:`"class"`
48-
- :python:`"union"`
49-
- :python:`"function"`
50-
- :python:`"member"`
51-
- :python:`"type"`
52-
- :python:`"concept"`
53-
- :python:`"enum"`
54-
- :python:`"enumerator"`
38+
.. autoclass:: sphinx_immaterial.apidoc.cpp.external_cpp_references.ExternalCppReference
39+
:members:
40+
:show-inheritance:
41+
:exclude-members: __new__
5542

5643
.. seealso::
57-
58-
- :doc:`cppreference`
44+
:doc:`cppreference`

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@
403403
# Python standard library types not present in object inventory.
404404
("py:class", "Pattern"),
405405
("py:class", "re.Pattern"),
406-
# Config option type
407-
("py:class", "ExternalCppReference"),
408406
# Example Python types
409407
("py:class", "example_mod.Foo"),
410408
("py:class", "alias_ex.MyUnqualifiedType"),

docs/task_lists.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Config variables
7878
.. rst:directive:option:: class
7979
:type: string
8080
81-
A space delimited list of qualified names that get used as the HTMl element's
81+
A space delimited list of qualified names that get used as the HTML element's
8282
``class`` attribute.
8383
8484
The ``class`` option is only applied to the containing ``div`` element.

sphinx_immaterial/apidoc/cpp/external_cpp_references.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,26 @@ class ObjectInfo(NamedTuple):
2626

2727

2828
class ExternalCppReference(TypedDict):
29+
"""A class used to represent each dictionary field's value specified in
30+
:confval:`external_cpp_references`."""
31+
2932
url: str
3033
"""URL to use as the target for references to this symbol."""
3134

3235
object_type: str
33-
"""C++ object type."""
36+
"""C++ object type.
37+
This should be one of the object types defined by the C++ domain:
38+
39+
.. hlist::
40+
- :python:`"class"`
41+
- :python:`"union"`
42+
- :python:`"function"`
43+
- :python:`"member"`
44+
- :python:`"type"`
45+
- :python:`"concept"`
46+
- :python:`"enum"`
47+
- :python:`"enumerator"`
48+
"""
3449

3550
desc: str
3651
"""Description text to include in the tooltip."""
@@ -124,6 +139,7 @@ def _load_from_config(app: sphinx.application.Sphinx) -> None:
124139
mappings = get_mappings(app)
125140

126141
for name, value in app.config.external_cpp_references.items():
142+
name = name.lstrip(":")
127143
mappings[name] = ObjectInfo(**value)
128144

129145

0 commit comments

Comments
 (0)