chiark / gitweb /
documentation/python: format also anchors for class/module members.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 10 Jul 2019 14:08:32 +0000 (16:08 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Jul 2019 17:11:08 +0000 (19:11 +0200)
First step towards symbol crosslinking.

35 files changed:
doc/documentation/python.rst
documentation/python.py
documentation/templates/python/details-enum.html
documentation/templates/python/entry-data.html
documentation/templates/python/entry-enum.html
documentation/templates/python/entry-function.html
documentation/templates/python/entry-property.html
documentation/test_python/CMakeLists.txt
documentation/test_python/content/content.html
documentation/test_python/inspect_all_property/inspect_all_property.html
documentation/test_python/inspect_annotations/inspect_annotations.Foo.html
documentation/test_python/inspect_annotations/inspect_annotations.html
documentation/test_python/inspect_annotations/math.html
documentation/test_python/inspect_annotations/math36.html
documentation/test_python/inspect_name_mapping/inspect_name_mapping.Class.html
documentation/test_python/inspect_name_mapping/inspect_name_mapping.html
documentation/test_python/inspect_name_mapping/inspect_name_mapping.submodule.html
documentation/test_python/inspect_string/inspect_string.Foo.html
documentation/test_python/inspect_string/inspect_string.Specials.html
documentation/test_python/inspect_string/inspect_string.html
documentation/test_python/link_formatting/c.link_formatting.Class.html
documentation/test_python/link_formatting/c.link_formatting.pybind.Foo.html [new file with mode: 0644]
documentation/test_python/link_formatting/link_formatting/__init__.py
documentation/test_python/link_formatting/link_formatting/pybind.cpp [new file with mode: 0644]
documentation/test_python/link_formatting/m.link_formatting.html
documentation/test_python/link_formatting/m.link_formatting.pybind.html [new file with mode: 0644]
documentation/test_python/link_formatting/s.classes.html
documentation/test_python/link_formatting/s.modules.html
documentation/test_python/pybind_enums/pybind_enums.html
documentation/test_python/pybind_name_mapping/pybind_name_mapping.Class.html
documentation/test_python/pybind_name_mapping/pybind_name_mapping.html
documentation/test_python/pybind_name_mapping/pybind_name_mapping.submodule.html
documentation/test_python/pybind_signatures/pybind_signatures.MyClass.html
documentation/test_python/pybind_signatures/pybind_signatures.html
documentation/test_python/test_link_formatting.py

index 1bb3a40184eab7fe788c1056f6a920b2be0a8038..0d21fb6c3de701f5b23dc4b1f2eae937559ca422 100644 (file)
@@ -254,6 +254,10 @@ Variable                            Description
                                     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`_
@@ -402,6 +406,21 @@ The ``type`` is an enum, if you don't want to fiddle with imports, compare
 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`_
 ====================
 
@@ -981,6 +1000,7 @@ Property                                Description
 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
@@ -1000,6 +1020,7 @@ Every item of :py:`enum.values` has the following properties:
 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
@@ -1014,6 +1035,7 @@ Property                    Description
 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
@@ -1065,6 +1087,7 @@ set to :py:`"..."` and the rest being empty.
 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
@@ -1083,6 +1106,7 @@ Property                            Description
 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
@@ -1150,3 +1174,5 @@ Module/class list is ordered in a way that all modules are before all classes.
     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.
index 8d8d45acc95e9ed6e16d70c2ab5ee06874ded127..6831b27f75d9476b0bb9ea08a63f67682c3978cc 100755 (executable)
@@ -29,6 +29,7 @@ import copy
 import docutils
 import enum
 import urllib.parse
+import hashlib
 import html
 import importlib
 import inspect
@@ -64,8 +65,12 @@ class EntryType(Enum):
     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?
@@ -73,6 +78,19 @@ def default_url_formatter(type: EntryType, path: List[str]) -> Tuple[str, str]:
     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,
@@ -125,7 +143,8 @@ default_config = {
     '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:
@@ -555,6 +574,7 @@ def extract_class_doc(state: State, path: List[str], class_):
 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
@@ -573,6 +593,7 @@ def extract_enum_doc(state: State, path: List[str], enum_):
         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
@@ -598,6 +619,7 @@ def extract_enum_doc(state: State, path: List[str], enum_):
         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
@@ -691,6 +713,10 @@ def extract_function_doc(state: State, parent, path: List[str], function) -> Lis
 
                 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
@@ -699,6 +725,7 @@ def extract_function_doc(state: State, parent, path: List[str], function) -> Lis
     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
@@ -744,6 +771,7 @@ def extract_property_doc(state: State, path: List[str], property):
 
     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
@@ -767,6 +795,7 @@ def extract_data_doc(state: State, parent, path: List[str], data):
 
     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
index aac8f6c9192541237879560a4dc36a1b6b574c2b..ea3bdff77300a37ba8c83eae2685f990e1ff778e 100644 (file)
@@ -1,6 +1,6 @@
-          <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>
@@ -11,7 +11,7 @@
               <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>
index 3e351daa12d7b1c732171714ef180d4e17a6119f..25930b1aaca809ceebd8803bd6bca053eb8ee1cb 100644 (file)
@@ -1,5 +1,5 @@
             <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>
index 773a0aa6c6becc185bfc32dda55a98776bedf826..e9620d64f55e07557c130d314e521016a6ca1d54 100644 (file)
@@ -1,5 +1,5 @@
             <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>
index 245f3c19cd8f5b0c34a5ca17aa6c5700b194d499..fc689ca3af3e83eb2fc2daaaa8c8197488eadff2 100644 (file)
@@ -1,5 +1,5 @@
             <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 %} -&gt; {{ 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 %} -&gt; {{ function.type }}{% endif %}</span>
             </dt>
             <dd>{{ function.summary }}</dd>
index 78852ee84803dcd140256b3d079cb6fba7baa46a..b608938a7cfffa4e9749f3944a1e7da606c0e660 100644 (file)
@@ -1,4 +1,4 @@
             <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>
index e38d63f78e636346070ef24fa155f6b865bb985b..9f41e4966f5ac16fd06cac8754dc3fba2f883af8 100644 (file)
@@ -32,6 +32,12 @@ foreach(target signatures enums submodules)
     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
index 01edd0af6957540cf35a839165c8373315d58752..604bbad76ad66790b8641a27406dac82cd8a087d 100644 (file)
@@ -50,7 +50,7 @@ tho.</p>
           <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>
index 8150aadd60bb0a2e3b29c8b58a172e5398e3d204..0e6a75de86a680296ee8b0f52a0bfbd3d5f742eb 100644 (file)
           <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>
@@ -71,7 +71,7 @@
           <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> = &#x27;Hey!&#x27;
+              <a href="#_private_data" class="m-doc-self" id="_private_data">_private_data</a> = &#x27;Hey!&#x27;
             </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>
index 7a1735dc15d9144ceed62cc2989295295e9d8082..a83a1714064e3eef8f0f0bd561ee92283c8977e9 100644 (file)
@@ -39,7 +39,7 @@
           <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>
@@ -48,7 +48,7 @@
           <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>
index 1d11437ab313bffdcf2f488c20679f1545a897eb..31af659e694f293aedcfa4b300c318010c538393 100644 (file)
           <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') -&gt; 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, &#x27;No.&#x27;)
+              <a href="#ANNOTATED_VAR" class="m-doc-self" id="ANNOTATED_VAR">ANNOTATED_VAR</a>: typing.Tuple[bool, str] = (False, &#x27;No.&#x27;)
             </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>
index 90c1e2f189b10220af58021bfcc7cc3a73f0d271..57768b0360d5c565aed1e365e625d5ab2a05f000 100644 (file)
@@ -39,11 +39,11 @@ mathematical functions defined by the C standard.</p>
           <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>
index f8cf25d27fae87e3d2d252aab3238dd17f369727..0964811cb1d624543927b98e21bf7f97e45abcb2 100644 (file)
@@ -39,7 +39,7 @@ mathematical functions defined by the C standard.</p>
           <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>
index 10f6a250fe7c32cea867fe2aab29842ec437608c..1772ea86c0fd329912b87961afc4a96c1b4a429f 100644 (file)
@@ -38,7 +38,7 @@
           <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) -&gt; 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) -&gt; inspect_name_mapping.Class</span>
             </dt>
             <dd>A method</dd>
           </dl>
index 1cc90c6e4ab669af6bededbe641c2a848727cb19..53ff83d659e022d5169cc6bb55017a78a2a6706d 100644 (file)
@@ -53,7 +53,7 @@
           <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">) -&gt; 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">) -&gt; inspect_name_mapping.Class</span>
             </dt>
             <dd>This function returns Class, *not* _sub.Foo</dd>
           </dl>
index 658657d8888b73b138a2ad9cf71b869d2b919c61..016ba03ef500cef7ff2dc2f763f7186d5acc4e6c 100644 (file)
@@ -38,7 +38,7 @@
           <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) -&gt; int</span>
             </dt>
             <dd>A function</dd>
index 206fba512b238368ed6108f93b6acb9b84e30d6b..ead3e32191d207ca6c392508a5ed9e28f28dccdf 100644 (file)
           <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>
@@ -79,7 +79,7 @@
           <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>
@@ -88,7 +88,7 @@
           <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>
@@ -97,7 +97,7 @@
           <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> = &#x27;BOO&#x27;
+              <a href="#A_DATA" class="m-doc-self" id="A_DATA">A_DATA</a> = &#x27;BOO&#x27;
             </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>
index 65e68fe4fa797ac48725133e3144e01cbc08b8e9..c8e9c1bd9fc44f8bc5e0109bfcd12f2c0ceddf40 100644 (file)
           <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>
index 72155565b6239a8d09c9173fd1e2f7fd8b27f108..846a56cde49a857236006cad35442213b28f015a 100644 (file)
           <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>
@@ -88,7 +88,7 @@
           <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>
index b54f5c28cf262694504eeaeaeade4df2dffa73e6..4989c9b0d7b1f846c00b1f801d0eb76124d34fa1 100644 (file)
@@ -48,6 +48,7 @@
               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>
diff --git a/documentation/test_python/link_formatting/c.link_formatting.pybind.Foo.html b/documentation/test_python/link_formatting/c.link_formatting.pybind.Foo.html
new file mode 100644 (file)
index 0000000..945727d
--- /dev/null
@@ -0,0 +1,85 @@
+<!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>) -&gt; 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>) -&gt; 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>) -&gt; 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>
index 5ccfb30be017b9a0551ae502b6534d0c1ed79b31..7e1c65d21a8b615e55b7df5443a88d6adb6b1325 100644 (file)
@@ -1,9 +1,24 @@
 """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
diff --git a/documentation/test_python/link_formatting/link_formatting/pybind.cpp b/documentation/test_python/link_formatting/link_formatting/pybind.cpp
new file mode 100644 (file)
index 0000000..9002a07
--- /dev/null
@@ -0,0 +1,36 @@
+#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");
+}
index cb18ca8b3b355dae1ca7afef19e1cb3947be411a..13a7059a9a91604b22d7bb8addfd11994a3b720c 100644 (file)
@@ -49,6 +49,9 @@
               <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>
@@ -56,6 +59,8 @@
         <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>
diff --git a/documentation/test_python/link_formatting/m.link_formatting.pybind.html b/documentation/test_python/link_formatting/m.link_formatting.pybind.html
new file mode 100644 (file)
index 0000000..d0210b1
--- /dev/null
@@ -0,0 +1,91 @@
+<!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>) -&gt; 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>) -&gt; 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>) -&gt; 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>) -&gt; int</span>
+            </dt>
+            <dd>Should have the same hash as Foo.a_function()</dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 7c6598b02d18c07ed3bdd1ca0650b1e6cf7a48d8..6751c5d342c5f482b479572234ab7ca6def6ce17 100644 (file)
           <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>
index 731ae5d6048f4fc56bc34edaa9d00713cdbd1d32..4e70ecc1e4ea3fbbb32a5dbcc7deb1700d6a0b19 100644 (file)
@@ -42,6 +42,7 @@
           <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>
index abfbad4e108aa5457302a37172b8572caa54c446..797aa90797fccbb11f269e77e2205aecde8333eb 100644 (file)
           <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>
index 50e0a0d1dbe8a7f61f72c2dfaa5915fdd0c00fa2..db2e17179aa5b3a120949745d70d48aa6f6cbe9d 100644 (file)
@@ -38,7 +38,7 @@
           <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">) -&gt; 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">) -&gt; pybind_name_mapping.Class</span>
             </dt>
             <dd>A method</dd>
           </dl>
index b261231a4c5eb4a62ce6b514ed96c3c0628e6c1f..0c28175e10edae7a0eaab56031ef84c0a286a6f6 100644 (file)
@@ -53,7 +53,7 @@
           <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">) -&gt; 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">) -&gt; pybind_name_mapping.Class</span>
             </dt>
             <dd>This function returns Class, *not* _sub.Foo</dd>
           </dl>
index 3fc5135cd26878c5d7fad25f03632e71757ab91e..fcdbee289038bef117b69c2c18e4a0ea1378c3b7 100644 (file)
@@ -38,7 +38,7 @@
           <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>) -&gt; int</span>
             </dt>
             <dd>A function</dd>
index bbc620206e9233e239d5a937e8787a80aed056ab..d4ea689e8e5b8776be4e387da1c851264a4a26dc 100644 (file)
@@ -41,7 +41,7 @@
           <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>) -&gt; 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>) -&gt; 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>) -&gt; int</span>
             </dt>
             <dd>Instance method with no args, &#x27;self&#x27; 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>) -&gt; 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 = &#x27;&lt;eh?&gt;&#x27;) -&gt; Tuple[float, int]</span>
             </dt>
@@ -72,7 +72,7 @@
           <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>
@@ -81,7 +81,7 @@
           <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>
index ddaa567492543e038c5bb60d94eb35adb1bec6ca..6e31c86b2dd4912c88923975bdf49027108724d3 100644 (file)
           <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>) -&gt; 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>) -&gt; 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>) -&gt; 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>) -&gt; 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>) -&gt; 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) -&gt; 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>) -&gt; 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>) -&gt; 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>
index 093b6318e245967ec120747c0426d1d9897746a6..bfc9563ed6d2a65c2213154d37e9fa6eaf607b6d 100644 (file)
@@ -28,7 +28,7 @@ import unittest
 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:
@@ -43,6 +43,23 @@ def custom_url_formatter(type: EntryType, path: List[str]) -> str:
 
     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)
@@ -51,13 +68,15 @@ class Test(BaseInspectTestCase):
         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'))
@@ -75,3 +94,7 @@ class Test(BaseInspectTestCase):
         # 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'))