First step towards symbol crosslinking.
for modules, classes, pages and index
pages. See `Custom URL formatters`_ for
more information.
+:py:`ID_FORMATTER: Callable` Function for creating link anchors for
+ module and class members. See
+ `Custom URL formatters`_ for more
+ information.
=================================== ===========================================
`Theme selection`_
that case the ``path`` has always just one item, one of :py:`'pages'`,
:py:`'modules'` or :py:`'classes'`.
+The :py:`ID_FORMATTER` handles formatting of anchors on a page. Again it takes
+an entry type (which in this case is always one of :py:`'ENUM'`,
+:py:`'ENUM_VALUE'`, :py:`'FUNCTION'`, :py:`'PROPERTY'`, :py:`'DATA'` or, in
+case of pybind11 code, :py:`'OVERLOADED_FUNCTION'`. The second parameter is
+again a path, being always just one item except for :py:`'ENUM_VALUE'` (in
+which case it's enum name and value name together) and for
+:py:`'OVERLOADED_FUNCTION'`, in which case it contains also a llist of argument
+types. The default implementation simply returns the the path concatenated with
+dashes:
+
+.. code:: py
+
+ def default_id_formatter(type: EntryType, path: List[str]) -> str:
+ return '-'.join(path)
+
`Module inspection`_
====================
Property Description
======================================= =======================================
:py:`enum.name` Enum name
+:py:`enum.id` Enum ID [4]_
:py:`enum.summary` Doc summary
:py:`enum.base` Base class from which the enum is
derived. Set to :py:`None` if no base
Property Description
=========================== ===================================================
:py:`value.name` Value name
+:py:`value.id` Value ID [4]_
:py:`value.value` Value value. Set to :py:`None` if no value is
available.
:py:`value.summary` Value doc summary
Property Description
=================================== ===========================================
:py:`function.name` Function name
+:py:`function.id` Function ID [4]_
:py:`function.summary` Doc summary
:py:`function.type` Function return type annotation [1]_
:py:`function.params` List of function parameters. See below for
Property Description
=================================== ===========================================
:py:`property.name` Property name
+:py:`property.id` Property ID [4]_
:py:`property.type` Property getter return type annotation [1]_
:py:`property.summary` Doc summary
:py:`property.is_writable` If the property is writable
Property Description
=================================== ===========================================
:py:`data.name` Data name
+:py:`data.id` Data ID [4]_
:py:`data.type` Data type
:py:`data.summary` Doc summary. Currently always empty.
:py:`data.value` Data value representation
the summary listing on top of the page to avoid unnecessary repetition.
.. [3] :py:`page.filename` and :py:`page.url` is generated by an URL formatter,
see `Custom URL formatters`_ for more information
+.. [4] :py:`i.id` is an ID used for linking to given entry on a page. Generated
+ by an anchor formatter, see `Custom URL formatters`_ for more information.
import docutils
import enum
import urllib.parse
+import hashlib
import html
import importlib
import inspect
ENUM = 4
ENUM_VALUE = 5
FUNCTION = 6
- PROPERTY = 7
- DATA = 8
+ # Denotes a potentially overloaded pybind11 function. Has to be here to
+ # be able to distinguish between zero-argument normal and pybind11
+ # functions.
+ OVERLOADED_FUNCTION = 7
+ PROPERTY = 8
+ DATA = 9
def default_url_formatter(type: EntryType, path: List[str]) -> Tuple[str, str]:
# TODO: what about nested pages, how to format?
assert '/' not in url # TODO
return url, url
+def default_id_formatter(type: EntryType, path: List[str]) -> str:
+ # Encode pybind11 function overloads into the anchor (hash them, like Rust
+ # does)
+ if type == EntryType.OVERLOADED_FUNCTION:
+ return path[0] + '-' + hashlib.sha1(', '.join([str(i) for i in path[1:]]).encode('utf-8')).hexdigest()[:5]
+
+ if type == EntryType.ENUM_VALUE:
+ assert len(path) == 2
+ return '-'.join(path)
+
+ assert len(path) == 1
+ return path[0]
+
default_config = {
'PROJECT_TITLE': 'My Python Project',
'PROJECT_SUBTITLE': None,
'SEARCH_BASE_URL': None,
'SEARCH_EXTERNAL_URL': None,
- 'URL_FORMATTER': default_url_formatter
+ 'URL_FORMATTER': default_url_formatter,
+ 'ID_FORMATTER': default_id_formatter
}
class State:
def extract_enum_doc(state: State, path: List[str], enum_):
out = Empty()
out.name = path[-1]
+ out.id = state.config['ID_FORMATTER'](EntryType.ENUM, path[-1:])
out.values = []
out.has_details = False
out.has_value_details = False
for i in enum_:
value = Empty()
value.name = i.name
+ value.id = state.config['ID_FORMATTER'](EntryType.ENUM_VALUE, path[-1:] + [i.name])
value.value = html.escape(repr(i.value))
# Value doc gets by default inherited from the enum, that's useless
for name, v in enum_.__members__.items():
value = Empty()
value. name = name
+ value.id = state.config['ID_FORMATTER'](EntryType.ENUM_VALUE, path[-1:] + [name])
value.value = int(v)
# TODO: once https://github.com/pybind/pybind11/pull/1160 is
# released, extract from class docs (until then the class
out.params += [param]
+ # Format the anchor. Pybind11 functions are sometimes overloaded,
+ # thus name alone is not enough.
+ out.id = state.config['ID_FORMATTER'](EntryType.OVERLOADED_FUNCTION, path[-1:] + [param.type for param in out.params])
+
overloads += [out]
return overloads
else:
out = Empty()
out.name = path[-1]
+ out.id = state.config['ID_FORMATTER'](EntryType.FUNCTION, path[-1:])
out.params = []
out.has_complex_params = False
out.has_details = False
out = Empty()
out.name = path[-1]
+ out.id = state.config['ID_FORMATTER'](EntryType.PROPERTY, path[-1:])
# TODO: external summary for properties
out.summary = extract_summary(state, {}, [], property.__doc__)
out.is_settable = property.fset is not None
out = Empty()
out.name = path[-1]
+ out.id = state.config['ID_FORMATTER'](EntryType.DATA, path[-1:])
# Welp. https://stackoverflow.com/questions/8820276/docstring-for-variable
out.summary = ''
out.has_details = False
- <section class="m-doc-details"><div>
+ <section class="m-doc-details" id="{{ enum.id }}"><div>
<h3>
- class {{ prefix }}<a href="" class="m-doc-self">{{ enum.name }}</a>({{ enum.base }})
+ class {{ prefix }}<a href="#{{ enum.id }}" class="m-doc-self">{{ enum.name }}</a>({{ enum.base }})
</h3>
{% if enum.summary %}
<p>{{ enum.summary }}</p>
<tbody>
{% for value in enum.values %}
<tr>
- <td><a href="" class="m-doc-self">{{ value.name }}</a></td>
+ <td><a href="#{{ value.id }}" id="{{ value.id }}" class="m-doc-self">{{ value.name }}</a></td>
<td>
{% if value.summary %}
<p>{{ value.summary }}</p>
<dt>
- <a href="" class="m-doc{% if not data.has_details %}-self{% endif %}">{{ data.name }}</a>{% if data.type %}: {{ data.type }}{% endif %}{% if data.value %} = {{ data.value }}{% endif %}
+ <a href="#{{ data.id }}" {% if data.has_details %}class="m-doc"{% else %}class="m-doc-self" id="{{ data.id }}"{% endif %}>{{ data.name }}</a>{% if data.type %}: {{ data.type }}{% endif %}{% if data.value %} = {{ data.value }}{% endif %}
{# This has to be here to avoid the newline being eaten #}
</dt>
<dt>
{% set j = joiner('\n ') %}
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc{% if not enum.has_details %}-self{% endif %}">{{ enum.name }}</a>{% if enum.base %}({{ enum.base }}){% endif %}: </span><span class="m-doc-wrap">{% for value in enum.values %}{{ j() }}<a href="" class="m-doc{% if not enum.has_details %}-self{% endif %}">{{ value.name }}</a>{% if value.value is not none %} = {{ value.value }}{% endif %}{% endfor %}</span>
+ <span class="m-doc-wrap-bumper">class <a href="#{{ enum.id }}" {% if enum.has_details %}class="m-doc"{% else %}class="m-doc-self" id="{{ enum.id }}"{% endif %}>{{ enum.name }}</a>{% if enum.base %}({{ enum.base }}){% endif %}: </span><span class="m-doc-wrap">{% for value in enum.values %}{{ j() }}<a href="#{{ value.id }}" {% if enum.has_details %}class="m-doc"{% else %}class="m-doc-self" id="{{ value.id }}"{% endif %}>{{ value.name }}</a>{% if value.value is not none %} = {{ value.value }}{% endif %}{% endfor %}</span>
</dt>
<dd>{{ enum.summary }}</dd>
<dt>
{% set j = joiner('\n ' if function.has_complex_params else ' ') %}
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc{% if not function.has_details %}-self{% endif %}">{{ function.name }}</a>(</span><span class="m-doc-wrap">{% for param in function.params %}{% if loop.index0 %}{% if function.params[loop.index0 - 1].kind == 'POSITIONAL_OR_KEYWORD' and param.kind == 'KEYWORD_ONLY' %},<span class="m-text m-dim"> *,</span>{% else %},{% endif %}{% endif %}{{ j() }}{% if param.kind == 'VAR_POSITIONAL' %}*{% elif param.kind == 'VAR_KEYWORD' %}**{% endif %}{{ param.name }}{% if param.type %}: {{ param.type }}{% endif %}{% if param.default %} = {{ param.default }}{% endif %}{% if param.kind == 'POSITIONAL_ONLY' and (loop.last or function.params[loop.index0 + 1].kind != 'POSITIONAL_ONLY') %}<span class="m-text m-dim">, /</span>{% endif %}{% endfor %}){% if function.type %} -> {{ function.type }}{% endif %}</span>
+ <span class="m-doc-wrap-bumper">def <a href="#{{ function.id }}" {% if function.has_details %}class="m-doc"{% else %}class="m-doc-self" id="{{ function.id }}"{% endif %}>{{ function.name }}</a>(</span><span class="m-doc-wrap">{% for param in function.params %}{% if loop.index0 %}{% if function.params[loop.index0 - 1].kind == 'POSITIONAL_OR_KEYWORD' and param.kind == 'KEYWORD_ONLY' %},<span class="m-text m-dim"> *,</span>{% else %},{% endif %}{% endif %}{{ j() }}{% if param.kind == 'VAR_POSITIONAL' %}*{% elif param.kind == 'VAR_KEYWORD' %}**{% endif %}{{ param.name }}{% if param.type %}: {{ param.type }}{% endif %}{% if param.default %} = {{ param.default }}{% endif %}{% if param.kind == 'POSITIONAL_ONLY' and (loop.last or function.params[loop.index0 + 1].kind != 'POSITIONAL_ONLY') %}<span class="m-text m-dim">, /</span>{% endif %}{% endfor %}){% if function.type %} -> {{ function.type }}{% endif %}</span>
</dt>
<dd>{{ function.summary }}</dd>
<dt>
- <a href="" class="m-doc{% if not property.has_details %}-self{% endif %}">{{ property.name }}</a>{% if property.type %}: {{ property.type }}{% endif %} <span class="m-label m-flat {% if property.is_settable %}m-success{% else %}m-warning{% endif %}">get{% if property.is_settable %} set{% endif %}{% if property.is_deletable %} del{% endif %}</span>
+ <a href="#{{ property.id }}" {% if property.has_details %}class="m-doc"{% else %}class="m-doc-self" id="{{ property.id }}"{% endif %}>{{ property.name }}</a>{% if property.type %}: {{ property.type }}{% endif %} <span class="m-label m-flat {% if property.is_settable %}m-success{% else %}m-warning{% endif %}">get{% if property.is_settable %} set{% endif %}{% if property.is_deletable %} del{% endif %}</span>
</dt>
<dd>{{ property.summary }}</dd>
set_target_properties(pybind_${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pybind_${target})
endforeach()
+# Need a special location for this one
+pybind11_add_module(pybind_link_formatting link_formatting/link_formatting/pybind.cpp)
+set_target_properties(pybind_link_formatting PROPERTIES
+ OUTPUT_NAME pybind
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/link_formatting/link_formatting)
+
# Need a special name for this one
pybind11_add_module(pybind_name_mapping pybind_name_mapping/sub.cpp)
set_target_properties(pybind_name_mapping PROPERTIES
<h2><a href="#data">Data</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">CONSTANT</a>: float = 3.14
+ <a href="#CONSTANT" class="m-doc-self" id="CONSTANT">CONSTANT</a>: float = 3.14
</dt>
<dd>This is finally a docstring for <code>content.CONSTANT</code></dd>
</dl>
<h2><a href="#enums">Enums</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc">_MyPrivateEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="" class="m-doc">VALUE</a> = 1
- <a href="" class="m-doc">ANOTHER</a> = 2
- <a href="" class="m-doc">YAY</a> = 3</span>
+ <span class="m-doc-wrap-bumper">class <a href="#_MyPrivateEnum" class="m-doc">_MyPrivateEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="#_MyPrivateEnum-VALUE" class="m-doc">VALUE</a> = 1
+ <a href="#_MyPrivateEnum-ANOTHER" class="m-doc">ANOTHER</a> = 2
+ <a href="#_MyPrivateEnum-YAY" class="m-doc">YAY</a> = 3</span>
</dt>
<dd></dd>
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc-self">UndocumentedEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="" class="m-doc-self">FLAG_ONE</a> = 1
- <a href="" class="m-doc-self">FLAG_SEVENTEEN</a> = 17</span>
+ <span class="m-doc-wrap-bumper">class <a href="#UndocumentedEnum" class="m-doc-self" id="UndocumentedEnum">UndocumentedEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="#UndocumentedEnum-FLAG_ONE" class="m-doc-self" id="UndocumentedEnum-FLAG_ONE">FLAG_ONE</a> = 1
+ <a href="#UndocumentedEnum-FLAG_SEVENTEEN" class="m-doc-self" id="UndocumentedEnum-FLAG_SEVENTEEN">FLAG_SEVENTEEN</a> = 17</span>
</dt>
<dd></dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">_private_but_exposed_func</a>(</span><span class="m-doc-wrap">)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#_private_but_exposed_func" class="m-doc-self" id="_private_but_exposed_func">_private_but_exposed_func</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd></dd>
</dl>
<h2><a href="#data">Data</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">_private_data</a> = 'Hey!'
+ <a href="#_private_data" class="m-doc-self" id="_private_data">_private_data</a> = 'Hey!'
</dt>
<dd></dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
- <section class="m-doc-details"><div>
+ <section class="m-doc-details" id="_MyPrivateEnum"><div>
<h3>
- class inspect_all_property.<wbr /><a href="" class="m-doc-self">_MyPrivateEnum</a>(enum.Enum)
+ class inspect_all_property.<wbr /><a href="#_MyPrivateEnum" class="m-doc-self">_MyPrivateEnum</a>(enum.Enum)
</h3>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
- <td><a href="" class="m-doc-self">VALUE</a></td>
+ <td><a href="#_MyPrivateEnum-VALUE" id="_MyPrivateEnum-VALUE" class="m-doc-self">VALUE</a></td>
<td>
<p>A value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">ANOTHER</a></td>
+ <td><a href="#_MyPrivateEnum-ANOTHER" id="_MyPrivateEnum-ANOTHER" class="m-doc-self">ANOTHER</a></td>
<td>
<p>Another value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">YAY</a></td>
+ <td><a href="#_MyPrivateEnum-YAY" id="_MyPrivateEnum-YAY" class="m-doc-self">YAY</a></td>
<td>
</td>
</tr>
<h2><a href="#methods">Methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">string_annotation</a>(</span><span class="m-doc-wrap">self: inspect_annotations.Foo)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#string_annotation" class="m-doc-self" id="string_annotation">string_annotation</a>(</span><span class="m-doc-wrap">self: inspect_annotations.Foo)</span>
</dt>
<dd>String annotations</dd>
</dl>
<h2><a href="#properties">Properties</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">a_property</a>: typing.List[bool] <span class="m-label m-flat m-warning">get</span>
+ <a href="#a_property" class="m-doc-self" id="a_property">a_property</a>: typing.List[bool] <span class="m-label m-flat m-warning">get</span>
</dt>
<dd>A property with a type annotation</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">annotated_positional_keyword</a>(</span><span class="m-doc-wrap">bar = False,<span class="m-text m-dim"> *,</span>
+ <span class="m-doc-wrap-bumper">def <a href="#annotated_positional_keyword" class="m-doc-self" id="annotated_positional_keyword">annotated_positional_keyword</a>(</span><span class="m-doc-wrap">bar = False,<span class="m-text m-dim"> *,</span>
foo: str,
**kwargs)</span>
</dt>
<dd>Function with explicitly delimited keyword args and type annotations</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">annotation</a>(</span><span class="m-doc-wrap">param: typing.List[int],
+ <span class="m-doc-wrap-bumper">def <a href="#annotation" class="m-doc-self" id="annotation">annotation</a>(</span><span class="m-doc-wrap">param: typing.List[int],
another: bool,
third: str = 'hello') -> inspect_annotations.Foo</span>
</dt>
<dd>An annotated function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">args_kwargs</a>(</span><span class="m-doc-wrap">a, b, *args, **kwargs)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#args_kwargs" class="m-doc-self" id="args_kwargs">args_kwargs</a>(</span><span class="m-doc-wrap">a, b, *args, **kwargs)</span>
</dt>
<dd>Function with args and kwargs</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">no_annotation</a>(</span><span class="m-doc-wrap">a, b, z)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#no_annotation" class="m-doc-self" id="no_annotation">no_annotation</a>(</span><span class="m-doc-wrap">a, b, z)</span>
</dt>
<dd>Non-annotated function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">no_annotation_default_param</a>(</span><span class="m-doc-wrap">param,
+ <span class="m-doc-wrap-bumper">def <a href="#no_annotation_default_param" class="m-doc-self" id="no_annotation_default_param">no_annotation_default_param</a>(</span><span class="m-doc-wrap">param,
another,
third = 'hello')</span>
</dt>
<dd>Non-annotated function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">partial_annotation</a>(</span><span class="m-doc-wrap">foo,
+ <span class="m-doc-wrap-bumper">def <a href="#partial_annotation" class="m-doc-self" id="partial_annotation">partial_annotation</a>(</span><span class="m-doc-wrap">foo,
param: typing.Tuple[int, int],
unannotated,
cls: inspect_annotations.Foo)</span>
</dt>
<dd>Partially annotated function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">positional_keyword</a>(</span><span class="m-doc-wrap">positional_kw,<span class="m-text m-dim"> *,</span> kw_only)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#positional_keyword" class="m-doc-self" id="positional_keyword">positional_keyword</a>(</span><span class="m-doc-wrap">positional_kw,<span class="m-text m-dim"> *,</span> kw_only)</span>
</dt>
<dd>Function with explicitly delimited keyword args</dd>
</dl>
<h2><a href="#data">Data</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">ANNOTATED_VAR</a>: typing.Tuple[bool, str] = (False, 'No.')
+ <a href="#ANNOTATED_VAR" class="m-doc-self" id="ANNOTATED_VAR">ANNOTATED_VAR</a>: typing.Tuple[bool, str] = (False, 'No.')
</dt>
<dd></dd>
<dt>
- <a href="" class="m-doc-self">UNANNOTATED_VAR</a> = 3.45
+ <a href="#UNANNOTATED_VAR" class="m-doc-self" id="UNANNOTATED_VAR">UNANNOTATED_VAR</a> = 3.45
</dt>
<dd></dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">pow</a>(</span><span class="m-doc-wrap">x, y<span class="m-text m-dim">, /</span>)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#pow" class="m-doc-self" id="pow">pow</a>(</span><span class="m-doc-wrap">x, y<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Return x**y (x to the power of y).</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">log</a>(</span><span class="m-doc-wrap">...)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#log" class="m-doc-self" id="log">log</a>(</span><span class="m-doc-wrap">...)</span>
</dt>
<dd>log(x, [base=math.e])
Return the logarithm of x to the given base.</dd>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">log</a>(</span><span class="m-doc-wrap">...)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#log" class="m-doc-self" id="log">log</a>(</span><span class="m-doc-wrap">...)</span>
</dt>
<dd>log(x[, base])</dd>
</dl>
<h2><a href="#methods">Methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">a_thing</a>(</span><span class="m-doc-wrap">self) -> inspect_name_mapping.Class</span>
+ <span class="m-doc-wrap-bumper">def <a href="#a_thing" class="m-doc-self" id="a_thing">a_thing</a>(</span><span class="m-doc-wrap">self) -> inspect_name_mapping.Class</span>
</dt>
<dd>A method</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">foo</a>(</span><span class="m-doc-wrap">) -> inspect_name_mapping.Class</span>
+ <span class="m-doc-wrap-bumper">def <a href="#foo" class="m-doc-self" id="foo">foo</a>(</span><span class="m-doc-wrap">) -> inspect_name_mapping.Class</span>
</dt>
<dd>This function returns Class, *not* _sub.Foo</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">foo</a>(</span><span class="m-doc-wrap">a: inspect_name_mapping.Class,
+ <span class="m-doc-wrap-bumper">def <a href="#foo" class="m-doc-self" id="foo">foo</a>(</span><span class="m-doc-wrap">a: inspect_name_mapping.Class,
b: int) -> int</span>
</dt>
<dd>A function</dd>
<h2><a href="#enums">Enums</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc">InnerEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="" class="m-doc">VALUE</a> = 0
- <a href="" class="m-doc">ANOTHER</a> = 1
- <a href="" class="m-doc">YAY</a> = 2</span>
+ <span class="m-doc-wrap-bumper">class <a href="#InnerEnum" class="m-doc">InnerEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="#InnerEnum-VALUE" class="m-doc">VALUE</a> = 0
+ <a href="#InnerEnum-ANOTHER" class="m-doc">ANOTHER</a> = 1
+ <a href="#InnerEnum-YAY" class="m-doc">YAY</a> = 2</span>
</dt>
<dd>Inner enum</dd>
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc-self">UndocumentedInnerEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="" class="m-doc-self">FLAG_ONE</a> = 1
- <a href="" class="m-doc-self">FLAG_SEVENTEEN</a> = 17</span>
+ <span class="m-doc-wrap-bumper">class <a href="#UndocumentedInnerEnum" class="m-doc-self" id="UndocumentedInnerEnum">UndocumentedInnerEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="#UndocumentedInnerEnum-FLAG_ONE" class="m-doc-self" id="UndocumentedInnerEnum-FLAG_ONE">FLAG_ONE</a> = 1
+ <a href="#UndocumentedInnerEnum-FLAG_SEVENTEEN" class="m-doc-self" id="UndocumentedInnerEnum-FLAG_SEVENTEEN">FLAG_SEVENTEEN</a> = 17</span>
</dt>
<dd></dd>
</dl>
<h2><a href="#classmethods">Class methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">func_on_class</a>(</span><span class="m-doc-wrap">a)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#func_on_class" class="m-doc-self" id="func_on_class">func_on_class</a>(</span><span class="m-doc-wrap">a)</span>
</dt>
<dd>A class method</dd>
</dl>
<h2><a href="#staticmethods">Static methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">static_func</a>(</span><span class="m-doc-wrap">a)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#static_func" class="m-doc-self" id="static_func">static_func</a>(</span><span class="m-doc-wrap">a)</span>
</dt>
<dd>A static method</dd>
</dl>
<h2><a href="#methods">Methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">func</a>(</span><span class="m-doc-wrap">self, a, b)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#func" class="m-doc-self" id="func">func</a>(</span><span class="m-doc-wrap">self, a, b)</span>
</dt>
<dd>A method</dd>
</dl>
<h2><a href="#properties">Properties</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">a_property</a> <span class="m-label m-flat m-warning">get</span>
+ <a href="#a_property" class="m-doc-self" id="a_property">a_property</a> <span class="m-label m-flat m-warning">get</span>
</dt>
<dd>A property</dd>
<dt>
- <a href="" class="m-doc-self">deletable_property</a> <span class="m-label m-flat m-warning">get del</span>
+ <a href="#deletable_property" class="m-doc-self" id="deletable_property">deletable_property</a> <span class="m-label m-flat m-warning">get del</span>
</dt>
<dd>Deletable property</dd>
<dt>
- <a href="" class="m-doc-self">writable_property</a> <span class="m-label m-flat m-success">get set</span>
+ <a href="#writable_property" class="m-doc-self" id="writable_property">writable_property</a> <span class="m-label m-flat m-success">get set</span>
</dt>
<dd>Writable property</dd>
</dl>
<h2><a href="#data">Data</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">A_DATA</a> = 'BOO'
+ <a href="#A_DATA" class="m-doc-self" id="A_DATA">A_DATA</a> = 'BOO'
</dt>
<dd></dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
- <section class="m-doc-details"><div>
+ <section class="m-doc-details" id="InnerEnum"><div>
<h3>
- class inspect_string.<wbr />Foo.<wbr /><a href="" class="m-doc-self">InnerEnum</a>(enum.Enum)
+ class inspect_string.<wbr />Foo.<wbr /><a href="#InnerEnum" class="m-doc-self">InnerEnum</a>(enum.Enum)
</h3>
<p>Inner enum</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
- <td><a href="" class="m-doc-self">VALUE</a></td>
+ <td><a href="#InnerEnum-VALUE" id="InnerEnum-VALUE" class="m-doc-self">VALUE</a></td>
<td>
<p>A value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">ANOTHER</a></td>
+ <td><a href="#InnerEnum-ANOTHER" id="InnerEnum-ANOTHER" class="m-doc-self">ANOTHER</a></td>
<td>
<p>Another value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">YAY</a></td>
+ <td><a href="#InnerEnum-YAY" id="InnerEnum-YAY" class="m-doc-self">YAY</a></td>
<td>
</td>
</tr>
<h2><a href="#dunder-methods">Special methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">__add__</a>(</span><span class="m-doc-wrap">self, other)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#__add__" class="m-doc-self" id="__add__">__add__</a>(</span><span class="m-doc-wrap">self, other)</span>
</dt>
<dd>Add a thing</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">__and__</a>(</span><span class="m-doc-wrap">self, other)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#__and__" class="m-doc-self" id="__and__">__and__</a>(</span><span class="m-doc-wrap">self, other)</span>
</dt>
<dd></dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">__init__</a>(</span><span class="m-doc-wrap">self)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#__init__" class="m-doc-self" id="__init__">__init__</a>(</span><span class="m-doc-wrap">self)</span>
</dt>
<dd>The constructor</dd>
</dl>
<h2><a href="#enums">Enums</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc">MyEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="" class="m-doc">VALUE</a> = 0
- <a href="" class="m-doc">ANOTHER</a> = 1
- <a href="" class="m-doc">YAY</a> = 2</span>
+ <span class="m-doc-wrap-bumper">class <a href="#MyEnum" class="m-doc">MyEnum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="#MyEnum-VALUE" class="m-doc">VALUE</a> = 0
+ <a href="#MyEnum-ANOTHER" class="m-doc">ANOTHER</a> = 1
+ <a href="#MyEnum-YAY" class="m-doc">YAY</a> = 2</span>
</dt>
<dd>An enum</dd>
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc-self">UndocumentedEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="" class="m-doc-self">FLAG_ONE</a> = 1
- <a href="" class="m-doc-self">FLAG_SEVENTEEN</a> = 17</span>
+ <span class="m-doc-wrap-bumper">class <a href="#UndocumentedEnum" class="m-doc-self" id="UndocumentedEnum">UndocumentedEnum</a>(enum.IntFlag): </span><span class="m-doc-wrap"><a href="#UndocumentedEnum-FLAG_ONE" class="m-doc-self" id="UndocumentedEnum-FLAG_ONE">FLAG_ONE</a> = 1
+ <a href="#UndocumentedEnum-FLAG_SEVENTEEN" class="m-doc-self" id="UndocumentedEnum-FLAG_SEVENTEEN">FLAG_SEVENTEEN</a> = 17</span>
</dt>
<dd></dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">function</a>(</span><span class="m-doc-wrap">)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#function" class="m-doc-self" id="function">function</a>(</span><span class="m-doc-wrap">)</span>
</dt>
<dd>A function</dd>
</dl>
<h2><a href="#data">Data</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">A_CONSTANT</a> = 3.24
+ <a href="#A_CONSTANT" class="m-doc-self" id="A_CONSTANT">A_CONSTANT</a> = 3.24
</dt>
<dd></dd>
<dt>
- <a href="" class="m-doc-self">ENUM_THING</a>
+ <a href="#ENUM_THING" class="m-doc-self" id="ENUM_THING">ENUM_THING</a>
</dt>
<dd></dd>
<dt>
- <a href="" class="m-doc-self">foo</a>
+ <a href="#foo" class="m-doc-self" id="foo">foo</a>
</dt>
<dd></dd>
</dl>
</section>
<section>
<h2>Enum documentation</h2>
- <section class="m-doc-details"><div>
+ <section class="m-doc-details" id="MyEnum"><div>
<h3>
- class inspect_string.<wbr /><a href="" class="m-doc-self">MyEnum</a>(enum.Enum)
+ class inspect_string.<wbr /><a href="#MyEnum" class="m-doc-self">MyEnum</a>(enum.Enum)
</h3>
<p>An enum</p>
<table class="m-table m-fullwidth m-flat m-doc">
<thead><tr><th style="width: 1%">Enumerators</th><th></th></tr></thead>
<tbody>
<tr>
- <td><a href="" class="m-doc-self">VALUE</a></td>
+ <td><a href="#MyEnum-VALUE" id="MyEnum-VALUE" class="m-doc-self">VALUE</a></td>
<td>
<p>A value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">ANOTHER</a></td>
+ <td><a href="#MyEnum-ANOTHER" id="MyEnum-ANOTHER" class="m-doc-self">ANOTHER</a></td>
<td>
<p>Another value</p>
</td>
</tr>
<tr>
- <td><a href="" class="m-doc-self">YAY</a></td>
+ <td><a href="#MyEnum-YAY" id="MyEnum-YAY" class="m-doc-self">YAY</a></td>
<td>
</td>
</tr>
Reference
<ul>
<li><a href="#classes">Classes</a></li>
+ <li><a href="#properties">Properties</a></li>
</ul>
</li>
</ul>
<dd>And a nice subclass, oh.</dd>
</dl>
</section>
+ <section id="properties">
+ <h2><a href="#properties">Properties</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <a href="#p-property" class="m-doc-self" id="p-property">property</a> <span class="m-label m-flat m-warning">get</span>
+ </dt>
+ <dd>A property.</dd>
+ </dl>
+ </section>
</div>
</div>
</div>
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>link_formatting.pybind.Foo | My Python Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="s.index.html#this-is-an-url" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Python Project</a>
+ <div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
+ <a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
+ <a id="m-navbar-hide" href="#" title="Hide navigation"></a>
+ </div>
+ <div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
+ <div class="m-row">
+ <ol class="m-col-t-12 m-col-m-none">
+ <li><a href="s.pages.html#this-is-an-url">Pages</a></li>
+ <li><a href="s.modules.html#this-is-an-url">Modules</a></li>
+ <li><a href="s.classes.html#this-is-an-url">Classes</a></li>
+ </ol>
+ <ol class="m-col-t-6 m-col-m-none" start="4">
+ <li><a href="p.page.html#this-is-an-url">A page</a></li>
+ <li><a href="m.link_formatting.html#this-is-an-url">A module</a></li>
+ <li><a href="c.link_formatting.Class.html#this-is-an-url">The class</a></li>
+ </ol>
+ </div>
+ </div>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ <span class="m-breadcrumb"><a href="m.link_formatting.html#this-is-an-url">link_formatting</a>.<wbr/></span><span class="m-breadcrumb"><a href="m.link_formatting.pybind.html#this-is-an-url">pybind</a>.<wbr/></span>Foo <span class="m-thin">class</span>
+ </h1>
+ <p>A class</p>
+ <div class="m-block m-default">
+ <h3>Contents</h3>
+ <ul>
+ <li>
+ Reference
+ <ul>
+ <li><a href="#staticmethods">Static methods</a></li>
+ <li><a href="#methods">Methods</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ <section id="staticmethods">
+ <h2><a href="#staticmethods">Static methods</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-a_function-46f8a" class="m-doc-self" id="o-a_function-46f8a">a_function</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>A static function that should have the same hash as takes_int()</dd>
+ </dl>
+ </section>
+ <section id="methods">
+ <h2><a href="#methods">Methods</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-bar-745a3" class="m-doc-self" id="o-bar-745a3">bar</a>(</span><span class="m-doc-wrap">self,
+ arg0: int<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Should have the same hash as foo() but not as a_function()</dd>
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-foo-745a3" class="m-doc-self" id="o-foo-745a3">foo</a>(</span><span class="m-doc-wrap">self,
+ arg0: int<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Should have the same hash as bar() but not as a_function()</dd>
+ </dl>
+ </section>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
"""This is a module."""
-from . import sub
+import enum
+
+from . import sub, pybind
class Class:
"""This is a nice class."""
class Sub:
"""And a nice subclass, oh."""
+
+ @property
+ def property(self):
+ """A property."""
+
+def function():
+ """A function."""
+
+SOME_DATA = 3.14
+
+class Enum(enum.Enum):
+ FIRST_VALUE = 1
+ SECOND_VALUE = 2
--- /dev/null
+#include <pybind11/pybind11.h>
+
+namespace py = pybind11;
+
+namespace {
+
+struct Foo {
+ static int aFunction(int a) { return 5 + a; }
+
+ int foo(int a) { return 3 + a; }
+
+ int bar(int a) { return 5 + a; }
+};
+
+int takesInt(int a) { return 3 + a; }
+
+int anOverloadedFunction(int b, float) { return int(b); }
+int anOverloadedFunction(int b) { return b; }
+int anOverloadedFunction(int b, Foo) { return b; }
+
+}
+
+PYBIND11_MODULE(pybind, m) {
+ m.doc() = "pybind11 overloaded function link formatting";
+
+ py::class_<Foo>{m, "Foo", "A class"}
+ .def_static("a_function", &Foo::aFunction, "A static function that should have the same hash as takes_int()")
+ .def("foo", &Foo::foo, "Should have the same hash as bar() but not as a_function()")
+ .def("bar", &Foo::bar, "Should have the same hash as foo() but not as a_function()");
+
+ m
+ .def("takes_int", &takesInt, "Should have the same hash as Foo.a_function()")
+ .def("an_overloaded_function", static_cast<int(*)(int, float)>(&anOverloadedFunction), "Each overload should have a different hash")
+ .def("an_overloaded_function", static_cast<int(*)(int)>(&anOverloadedFunction), "Each overload should have a different hash")
+ .def("an_overloaded_function", static_cast<int(*)(int, Foo)>(&anOverloadedFunction), "Each overload should have a different hash");
+}
<ul>
<li><a href="#packages">Modules</a></li>
<li><a href="#classes">Classes</a></li>
+ <li><a href="#enums">Enums</a></li>
+ <li><a href="#functions">Functions</a></li>
+ <li><a href="#data">Data</a></li>
</ul>
</li>
</ul>
<section id="namespaces">
<h2><a href="#namespaces">Modules</a></h2>
<dl class="m-doc">
+ <dt>module <a href="m.link_formatting.pybind.html#this-is-an-url" class="m-doc">pybind</a></dt>
+ <dd>pybind11 overloaded function link formatting</dd>
<dt>module <a href="m.link_formatting.sub.html#this-is-an-url" class="m-doc">sub</a></dt>
<dd>This is a nice submodule.</dd>
</dl>
<dd>This is a nice class.</dd>
</dl>
</section>
+ <section id="enums">
+ <h2><a href="#enums">Enums</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">class <a href="#e-Enum" class="m-doc-self" id="e-Enum">Enum</a>(enum.Enum): </span><span class="m-doc-wrap"><a href="#v-Enum-FIRST_VALUE" class="m-doc-self" id="v-Enum-FIRST_VALUE">FIRST_VALUE</a> = 1
+ <a href="#v-Enum-SECOND_VALUE" class="m-doc-self" id="v-Enum-SECOND_VALUE">SECOND_VALUE</a> = 2</span>
+ </dt>
+ <dd></dd>
+ </dl>
+ </section>
+ <section id="functions">
+ <h2><a href="#functions">Functions</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#f-function" class="m-doc-self" id="f-function">function</a>(</span><span class="m-doc-wrap">)</span>
+ </dt>
+ <dd>A function.</dd>
+ </dl>
+ </section>
+ <section id="data">
+ <h2><a href="#data">Data</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <a href="#d-SOME_DATA" class="m-doc-self" id="d-SOME_DATA">SOME_DATA</a> = 3.14
+ </dt>
+ <dd></dd>
+ </dl>
+ </section>
</div>
</div>
</div>
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>link_formatting.pybind | My Python Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="s.index.html#this-is-an-url" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Python Project</a>
+ <div class="m-col-t-4 m-hide-m m-text-right m-nopadr">
+ <a id="m-navbar-show" href="#navigation" title="Show navigation"></a>
+ <a id="m-navbar-hide" href="#" title="Hide navigation"></a>
+ </div>
+ <div id="m-navbar-collapse" class="m-col-t-12 m-show-m m-col-m-none m-right-m">
+ <div class="m-row">
+ <ol class="m-col-t-12 m-col-m-none">
+ <li><a href="s.pages.html#this-is-an-url">Pages</a></li>
+ <li><a href="s.modules.html#this-is-an-url">Modules</a></li>
+ <li><a href="s.classes.html#this-is-an-url">Classes</a></li>
+ </ol>
+ <ol class="m-col-t-6 m-col-m-none" start="4">
+ <li><a href="p.page.html#this-is-an-url">A page</a></li>
+ <li><a href="m.link_formatting.html#this-is-an-url">A module</a></li>
+ <li><a href="c.link_formatting.Class.html#this-is-an-url">The class</a></li>
+ </ol>
+ </div>
+ </div>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ <span class="m-breadcrumb"><a href="m.link_formatting.html#this-is-an-url">link_formatting</a>.<wbr/></span>pybind <span class="m-thin">module</span>
+ </h1>
+ <p>pybind11 overloaded function link formatting</p>
+ <div class="m-block m-default">
+ <h3>Contents</h3>
+ <ul>
+ <li>
+ Reference
+ <ul>
+ <li><a href="#classes">Classes</a></li>
+ <li><a href="#functions">Functions</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ <section id="classes">
+ <h2><a href="#classes">Classes</a></h2>
+ <dl class="m-doc">
+ <dt>class <a href="c.link_formatting.pybind.Foo.html#this-is-an-url" class="m-doc">Foo</a></dt>
+ <dd>A class</dd>
+ </dl>
+ </section>
+ <section id="functions">
+ <h2><a href="#functions">Functions</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-an_overloaded_function-8f19c" class="m-doc-self" id="o-an_overloaded_function-8f19c">an_overloaded_function</a>(</span><span class="m-doc-wrap">arg0: int,
+ arg1: float<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Each overload should have a different hash</dd>
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-an_overloaded_function-46f8a" class="m-doc-self" id="o-an_overloaded_function-46f8a">an_overloaded_function</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Each overload should have a different hash</dd>
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-an_overloaded_function-d36ce" class="m-doc-self" id="o-an_overloaded_function-d36ce">an_overloaded_function</a>(</span><span class="m-doc-wrap">arg0: int,
+ arg1: link_formatting.pybind.Foo<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Each overload should have a different hash</dd>
+ <dt>
+ <span class="m-doc-wrap-bumper">def <a href="#o-takes_int-46f8a" class="m-doc-self" id="o-takes_int-46f8a">takes_int</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>) -> int</span>
+ </dt>
+ <dd>Should have the same hash as Foo.a_function()</dd>
+ </dl>
+ </section>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
<li class="m-doc-collapsible">
<a href="#" onclick="return toggle(this)">module</a> <a href="m.link_formatting.html#this-is-an-url" class="m-doc">link_formatting</a> <span class="m-doc">This is a module.</span>
<ul class="m-doc">
+ <li class="m-doc-collapsible collapsed">
+ <a href="#" onclick="return toggle(this)">module</a> <a href="m.link_formatting.pybind.html#this-is-an-url" class="m-doc">pybind</a> <span class="m-doc">pybind11 overloaded function link formatting</span>
+ <ul class="m-doc">
+ <li>class <a href="c.link_formatting.pybind.Foo.html#this-is-an-url" class="m-doc">Foo</a> <span class="m-doc">A class</span></li>
+ </ul>
+ </li>
<li>module <a href="m.link_formatting.sub.html#this-is-an-url" class="m-doc">sub</a> <span class="m-doc">This is a nice submodule.</span></li>
<li class="m-doc-collapsible collapsed">
<a href="#" onclick="return toggle(this)">class</a> <a href="c.link_formatting.Class.html#this-is-an-url" class="m-doc">Class</a> <span class="m-doc">This is a nice class.</span>
<li class="m-doc-collapsible">
<a href="#" onclick="return toggle(this)">module</a> <a href="m.link_formatting.html#this-is-an-url" class="m-doc">link_formatting</a> <span class="m-doc">This is a module.</span>
<ul class="m-doc">
+ <li>module <a href="m.link_formatting.pybind.html#this-is-an-url" class="m-doc">pybind</a> <span class="m-doc">pybind11 overloaded function link formatting</span></li>
<li>module <a href="m.link_formatting.sub.html#this-is-an-url" class="m-doc">sub</a> <span class="m-doc">This is a nice submodule.</span></li>
</ul>
</li>
<h2><a href="#enums">Enums</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc-self">MyEnum</a>: </span><span class="m-doc-wrap"><a href="" class="m-doc-self">First</a> = 0
- <a href="" class="m-doc-self">Second</a> = 1
- <a href="" class="m-doc-self">Third</a> = 74
- <a href="" class="m-doc-self">CONSISTANTE</a> = -5</span>
+ <span class="m-doc-wrap-bumper">class <a href="#MyEnum" class="m-doc-self" id="MyEnum">MyEnum</a>: </span><span class="m-doc-wrap"><a href="#MyEnum-First" class="m-doc-self" id="MyEnum-First">First</a> = 0
+ <a href="#MyEnum-Second" class="m-doc-self" id="MyEnum-Second">Second</a> = 1
+ <a href="#MyEnum-Third" class="m-doc-self" id="MyEnum-Third">Third</a> = 74
+ <a href="#MyEnum-CONSISTANTE" class="m-doc-self" id="MyEnum-CONSISTANTE">CONSISTANTE</a> = -5</span>
</dt>
<dd>An enum without value docs :(</dd>
<dt>
- <span class="m-doc-wrap-bumper">class <a href="" class="m-doc-self">SixtyfourBitFlag</a>: </span><span class="m-doc-wrap"><a href="" class="m-doc-self">Yes</a> = 1000000000000
- <a href="" class="m-doc-self">No</a> = 18446744073709551615</span>
+ <span class="m-doc-wrap-bumper">class <a href="#SixtyfourBitFlag" class="m-doc-self" id="SixtyfourBitFlag">SixtyfourBitFlag</a>: </span><span class="m-doc-wrap"><a href="#SixtyfourBitFlag-Yes" class="m-doc-self" id="SixtyfourBitFlag-Yes">Yes</a> = 1000000000000
+ <a href="#SixtyfourBitFlag-No" class="m-doc-self" id="SixtyfourBitFlag-No">No</a> = 18446744073709551615</span>
</dt>
<dd>64-bit flags</dd>
</dl>
<h2><a href="#staticmethods">Static methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">a_thing</a>(</span><span class="m-doc-wrap">) -> pybind_name_mapping.Class</span>
+ <span class="m-doc-wrap-bumper">def <a href="#a_thing-da39a" class="m-doc-self" id="a_thing-da39a">a_thing</a>(</span><span class="m-doc-wrap">) -> pybind_name_mapping.Class</span>
</dt>
<dd>A method</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">foo</a>(</span><span class="m-doc-wrap">) -> pybind_name_mapping.Class</span>
+ <span class="m-doc-wrap-bumper">def <a href="#foo" class="m-doc-self" id="foo">foo</a>(</span><span class="m-doc-wrap">) -> pybind_name_mapping.Class</span>
</dt>
<dd>This function returns Class, *not* _sub.Foo</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">foo</a>(</span><span class="m-doc-wrap">arg0: pybind_name_mapping.Class,
+ <span class="m-doc-wrap-bumper">def <a href="#foo-c5914" class="m-doc-self" id="foo-c5914">foo</a>(</span><span class="m-doc-wrap">arg0: pybind_name_mapping.Class,
arg1: int<span class="m-text m-dim">, /</span>) -> int</span>
</dt>
<dd>A function</dd>
<h2><a href="#staticmethods">Static methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">static_function</a>(</span><span class="m-doc-wrap">arg0: int,
+ <span class="m-doc-wrap-bumper">def <a href="#static_function-8f19c" class="m-doc-self" id="static_function-8f19c">static_function</a>(</span><span class="m-doc-wrap">arg0: int,
arg1: float<span class="m-text m-dim">, /</span>) -> pybind_signatures.MyClass</span>
</dt>
<dd>Static method with positional-only args</dd>
<h2><a href="#methods">Methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">another</a>(</span><span class="m-doc-wrap">self<span class="m-text m-dim">, /</span>) -> int</span>
+ <span class="m-doc-wrap-bumper">def <a href="#another-6eef6" class="m-doc-self" id="another-6eef6">another</a>(</span><span class="m-doc-wrap">self<span class="m-text m-dim">, /</span>) -> int</span>
</dt>
<dd>Instance method with no args, 'self' is thus position-only</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">instance_function</a>(</span><span class="m-doc-wrap">self,
+ <span class="m-doc-wrap-bumper">def <a href="#instance_function-a8577" class="m-doc-self" id="instance_function-a8577">instance_function</a>(</span><span class="m-doc-wrap">self,
arg0: int,
arg1: str<span class="m-text m-dim">, /</span>) -> Tuple[float, int]</span>
</dt>
<dd>Instance method with positional-only args</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">instance_function_kwargs</a>(</span><span class="m-doc-wrap">self,
+ <span class="m-doc-wrap-bumper">def <a href="#instance_function_kwargs-a8577" class="m-doc-self" id="instance_function_kwargs-a8577">instance_function_kwargs</a>(</span><span class="m-doc-wrap">self,
hey: int,
what: str = '<eh?>') -> Tuple[float, int]</span>
</dt>
<h2><a href="#dunder-methods">Special methods</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">__init__</a>(</span><span class="m-doc-wrap">self<span class="m-text m-dim">, /</span>)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#__init__-6eef6" class="m-doc-self" id="__init__-6eef6">__init__</a>(</span><span class="m-doc-wrap">self<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Constructor</dd>
</dl>
<h2><a href="#properties">Properties</a></h2>
<dl class="m-doc">
<dt>
- <a href="" class="m-doc-self">foo</a>: float <span class="m-label m-flat m-success">get set</span>
+ <a href="#foo" class="m-doc-self" id="foo">foo</a>: float <span class="m-label m-flat m-success">get set</span>
</dt>
<dd>A read/write property</dd>
</dl>
<h2><a href="#functions">Functions</a></h2>
<dl class="m-doc">
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">crazy_signature</a>(</span><span class="m-doc-wrap">…)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#crazy_signature-6eef6" class="m-doc-self" id="crazy_signature-6eef6">crazy_signature</a>(</span><span class="m-doc-wrap">…)</span>
</dt>
<dd>Function that failed to get parsed</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">duck</a>(</span><span class="m-doc-wrap">*args, **kwargs)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#duck-9024d" class="m-doc-self" id="duck-9024d">duck</a>(</span><span class="m-doc-wrap">*args, **kwargs)</span>
</dt>
<dd>A function taking args/kwargs directly</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">overloaded</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>) -> str</span>
+ <span class="m-doc-wrap-bumper">def <a href="#overloaded-46f8a" class="m-doc-self" id="overloaded-46f8a">overloaded</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>) -> str</span>
</dt>
<dd>Overloaded for ints</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">overloaded</a>(</span><span class="m-doc-wrap">arg0: float<span class="m-text m-dim">, /</span>) -> bool</span>
+ <span class="m-doc-wrap-bumper">def <a href="#overloaded-685e8" class="m-doc-self" id="overloaded-685e8">overloaded</a>(</span><span class="m-doc-wrap">arg0: float<span class="m-text m-dim">, /</span>) -> bool</span>
</dt>
<dd>Overloaded for floats</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">scale</a>(</span><span class="m-doc-wrap">arg0: int,
+ <span class="m-doc-wrap-bumper">def <a href="#scale-8f19c" class="m-doc-self" id="scale-8f19c">scale</a>(</span><span class="m-doc-wrap">arg0: int,
arg1: float<span class="m-text m-dim">, /</span>) -> int</span>
</dt>
<dd>Scale an integer</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">scale_kwargs</a>(</span><span class="m-doc-wrap">a: int,
+ <span class="m-doc-wrap-bumper">def <a href="#scale_kwargs-8f19c" class="m-doc-self" id="scale_kwargs-8f19c">scale_kwargs</a>(</span><span class="m-doc-wrap">a: int,
argument: float) -> int</span>
</dt>
<dd>Scale an integer, kwargs</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">taking_a_list_returning_a_tuple</a>(</span><span class="m-doc-wrap">arg0: List[float]<span class="m-text m-dim">, /</span>) -> Tuple[int, int, int]</span>
+ <span class="m-doc-wrap-bumper">def <a href="#taking_a_list_returning_a_tuple-54d79" class="m-doc-self" id="taking_a_list_returning_a_tuple-54d79">taking_a_list_returning_a_tuple</a>(</span><span class="m-doc-wrap">arg0: List[float]<span class="m-text m-dim">, /</span>) -> Tuple[int, int, int]</span>
</dt>
<dd>Takes a list, returns a tuple</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-fe11a" class="m-doc-self" id="tenOverloads-fe11a">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
arg1: float<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-8f19c" class="m-doc-self" id="tenOverloads-8f19c">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
arg1: float<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-bd997" class="m-doc-self" id="tenOverloads-bd997">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
arg1: float<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-8710e" class="m-doc-self" id="tenOverloads-8710e">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
arg1: int<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-e9329" class="m-doc-self" id="tenOverloads-e9329">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
arg1: int<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-3d438" class="m-doc-self" id="tenOverloads-3d438">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
arg1: int<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-841cb" class="m-doc-self" id="tenOverloads-841cb">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: float,
arg1: bool<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-a6f98" class="m-doc-self" id="tenOverloads-a6f98">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: int,
arg1: bool<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-2d308" class="m-doc-self" id="tenOverloads-2d308">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: bool,
arg1: bool<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: str,
+ <span class="m-doc-wrap-bumper">def <a href="#tenOverloads-6e57b" class="m-doc-self" id="tenOverloads-6e57b">tenOverloads</a>(</span><span class="m-doc-wrap">arg0: str,
arg1: str<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Ten overloads of a function</dd>
<dt>
- <span class="m-doc-wrap-bumper">def <a href="" class="m-doc-self">void_function</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>)</span>
+ <span class="m-doc-wrap-bumper">def <a href="#void_function-46f8a" class="m-doc-self" id="void_function-46f8a">void_function</a>(</span><span class="m-doc-wrap">arg0: int<span class="m-text m-dim">, /</span>)</span>
</dt>
<dd>Returns nothing</dd>
</dl>
from typing import List
from . import BaseInspectTestCase
-from python import EntryType
+from python import EntryType, default_id_formatter
def custom_url_formatter(type: EntryType, path: List[str]) -> str:
if type == EntryType.CLASS:
return filename, filename + "#this-is-an-url"
+def custom_id_formatter(type: EntryType, path: List[str]) -> str:
+ if type == EntryType.FUNCTION:
+ return 'f-' + '-'.join(path)
+ if type == EntryType.OVERLOADED_FUNCTION:
+ # Reuse the original hasher so we can test its behavior
+ return 'o-' + default_id_formatter(type, path)
+ if type == EntryType.PROPERTY:
+ return 'p-' + '-'.join(path)
+ if type == EntryType.ENUM:
+ return 'e-' + '-'.join(path)
+ if type == EntryType.ENUM_VALUE:
+ return 'v-' + '-'.join(path)
+ if type == EntryType.DATA:
+ return 'd-' + '-'.join(path)
+
+ assert False
+
class Test(BaseInspectTestCase):
def __init__(self, *args, **kwargs):
super().__init__(__file__, '', *args, **kwargs)
self.run_python({
'INPUT_PAGES': ['page.rst'],
'URL_FORMATTER': custom_url_formatter,
+ 'ID_FORMATTER': custom_id_formatter,
'LINKS_NAVBAR1': [
('Pages', 'pages', []),
('Modules', 'modules', []),
('Classes', 'classes', [])],
'LINKS_NAVBAR2': [('A page', 'page', []),
('A module', 'link_formatting', []),
- ('The class', ['link_formatting', 'Class'], [])]
+ ('The class', ['link_formatting', 'Class'], [])],
+ 'PYBIND11_COMPATIBILITY': True
})
self.assertEqual(*self.actual_expected_contents('m.link_formatting.html'))
self.assertEqual(*self.actual_expected_contents('m.link_formatting.sub.html'))
# There's nothing inside s.index.html that wouldn't be already covered
# by others
self.assertTrue(os.path.exists(os.path.join(self.path, 'output/s.index.html')))
+
+ # Verify pybind11 overloaded function hashing as well
+ self.assertEqual(*self.actual_expected_contents('m.link_formatting.pybind.html'))
+ self.assertEqual(*self.actual_expected_contents('c.link_formatting.pybind.Foo.html'))