<% import os import pdoc from pdoc.html_helpers import extract_toc, glimpse, to_html as _to_html, format_git_link def link(dobj: pdoc.Doc, name=None): name = name or dobj.qualname + ('()' if isinstance(dobj, pdoc.Function) else '') if isinstance(dobj, pdoc.External) and not external_links: return name url = dobj.url(relative_to=module, link_prefix=link_prefix, top_ancestor=not show_inherited_members) return f'{name}' def to_html(text): return _to_html(text, docformat=docformat, module=module, link=link, latex_math=latex_math) def get_annotation(bound_method, sep=':'): annot = show_type_annotations and bound_method(link=link) or '' if annot: annot = ' ' + sep + '\N{NBSP}' + annot return annot %> <%def name="ident(name)">${name} <%def name="show_source(d)"> % if (show_source_code or git_link_template) and d.source and d.obj is not getattr(d.inherits, 'obj', None): <% git_link = format_git_link(git_link_template, d) %> % if show_source_code:
Expand source code % if git_link: Browse git %endif

    ${d.source | h}

% elif git_link:
Browse git
%endif %endif <%def name="show_desc(d, short=False)"> <% inherits = ' inherited' if d.inherits else '' docstring = glimpse(d.docstring) if short or inherits else d.docstring %> % if d.inherits:

Inherited from: % if hasattr(d.inherits, 'cls'): `${link(d.inherits.cls)}`.`${link(d.inherits, d.name)}` % else: `${link(d.inherits)}` % endif

% endif
${docstring | to_html}
% if not isinstance(d, pdoc.Module): ${show_source(d)} % endif <%def name="show_module_list(modules)">

# Python module list

% if not modules:

No modules found.

% else:

% for name, desc in modules:
${name}
  ${desc | glimpse, to_html}
% endfor

% endif <%def name="show_column_list(items)"> <% two_column = len(items) >= 6 and all(len(i.name) < 20 for i in items) %>

% for item in items:
- `${link(item, item.name)}`
% endfor

<%def name="show_module(module)"> <% variables = module.variables(sort=sort_identifiers) classes = module.classes(sort=sort_identifiers) functions = module.functions(sort=sort_identifiers) submodules = module.submodules() %> <%def name="show_func(f)">
`<% params = ', '.join(f.params(annotate=show_type_annotations, link=link)) return_type = get_annotation(f.return_annotation, '\N{non-breaking hyphen}>') %> ${f.funcdef()} ${ident(f.name)}(${params})${return_type}`
  ${show_desc(f)}
${module.docstring | to_html} ${show_source(module)}
% if submodules:

## Sub-modules

% for m in submodules:
`${link(m)}`
  ${show_desc(m, short=True)}
% endfor

% endif
% if variables:

## Global variables

% for v in variables: <% return_type = get_annotation(v.type_annotation) %>
`var ${ident(v.name)}${return_type}`
  ${show_desc(v)}
% endfor

% endif
% if functions:

## Functions

% for f in functions: ${show_func(f)} % endfor

% endif
% if classes:

## Classes

% for c in classes: <% class_vars = c.class_variables(show_inherited_members, sort=sort_identifiers) smethods = c.functions(show_inherited_members, sort=sort_identifiers) inst_vars = c.instance_variables(show_inherited_members, sort=sort_identifiers) methods = c.methods(show_inherited_members, sort=sort_identifiers) mro = c.mro() subclasses = c.subclasses() params = ', '.join(c.params(annotate=show_type_annotations, link=link)) %>
`class ${ident(c.name)} % if params: (${params}) % endif`
  ${show_desc(c)} % if mro:

  ### Ancestors

  % for cls in mro:
  - ${link(cls)}
  % endfor
  %endif % if subclasses:

  ### Subclasses

  % for sub in subclasses:
  - ${link(sub)}
  % endfor
  % endif % if class_vars:

  ### Class variables

  % for v in class_vars: <% return_type = get_annotation(v.type_annotation) %>
  `var ${ident(v.name)}${return_type}`
    ${show_desc(v)}
  % endfor
  % endif % if smethods:

  ### Static methods

  % for f in smethods: ${show_func(f)} % endfor
  % endif % if inst_vars:

  ### Instance variables

  % for v in inst_vars: <% return_type = get_annotation(v.type_annotation) %>
  `var ${ident(v.name)}${return_type}`
    ${show_desc(v)}
  % endfor
  % endif % if methods:

  ### Methods

  % for f in methods: ${show_func(f)} % endfor
  % endif % if not show_inherited_members: <% members = c.inherited_members() %> % if members:

  ### Inherited members

  % for cls, mems in members:
  - `${link(cls)}`:
    % for m in mems:
    - `${link(m, name=m.name)}`
    % endfor
  % endfor
  % endif % endif
% endfor

% endif
<%def name="module_index(module)"> <% variables = module.variables(sort=sort_identifiers) classes = module.classes(sort=sort_identifiers) functions = module.functions(sort=sort_identifiers) submodules = module.submodules() supermodule = module.supermodule %>
<% module_list = 'modules' in context.keys() # Whether we're showing module list in server mode %> % if module_list: % else: ${module.name} API documentation % endif % if syntax_highlighting: %endif <%namespace name="css" file="css.mako" />
% if google_analytics:
% endif % if google_search_query:
% endif % if latex_math:
% endif % if syntax_highlighting:
% endif <%include file="head.mako"/>
% if module_list:
${show_module_list(modules)}
% else:
${show_module(module)}
${module_index(module)} % endif
% if http_server and module: ## Auto-reload on file change in dev mode
% endif