Fixed more broken link generation in docs.
if fqn in unlocatable_external_refs:
return
- if fqn in dir(builtins):
- fqn = "builtins." + fqn
-
if fqn not in located_external_refs:
print("attempting to find intersphinx reference for", fqn)
for base_url, inv in inventories.items():
from pdoc.html_helpers import extract_toc, glimpse, to_html as _to_html, format_git_link
- QUAL_ABC = "abc"
+ QUAL_ABC = "abstract"
QUAL_ASYNC_DEF = "async def"
QUAL_CLASS = "class"
QUAL_DATACLASS = "dataclass"
prefix = ""
name = name or dobj.name
+ if name.startswith("builtins."):
+ _, _, name = name.partition("builtins.")
+
if with_prefixes:
if isinstance(dobj, pdoc.Function):
if not hide_ref and dobj.module.name != dobj.obj.__module__:
else:
fqn = dobj.name
+
url = discover_source(fqn)
+ if url is None:
+ url = discover_source(name)
if url is None:
return name if not with_prefixes else f"{QUAL_EXTERNAL} {name}"
return name
def get_annotation(bound_method, sep=':'):
- annot = show_type_annotations and bound_method(link=link) or ''
+ annot = bound_method(link=link) or ''
annot = annot.replace("NoneType", "None")
# Remove quotes.
if annot.startswith("'") and annot.endswith("'"):
return annot
def to_html(text):
- return _to_html(text, module=module, link=link, latex_math=latex_math)
+ text = _to_html(text, module=module, link=link, latex_math=latex_math)
+ replacements = [
+ ('class="admonition info"', 'class="alert alert-primary"'),
+ ('class="admonition warning"', 'class="alert alert-warning"'),
+ ('class="admonition danger"', 'class="alert alert-danger"'),
+ ('class="admonition note"', 'class="alert alert-success"')
+ ]
+
+ for before, after in replacements:
+ text = text.replace(before, after)
+
+ return text
%>
<%def name="ident(name)"><span class="ident">${name}</span></%def>
</%def>
<%def name="show_var(v, is_nested=False)">
- <% return_type = get_annotation(v.type_annotation) %>
+ <%
+ return_type = get_annotation(v.type_annotation)
+ %>
<dt>
<pre><code class="python">${link(v, anchor=True)}${return_type}</code></pre>
</dt>
