<% import os import pdoc from pdoc.html_helpers import extract_toc, glimpse, to_html as _to_html, format_git_link def link(d, name=None, fmt='{}'): name = fmt.format(name or d.qualname + ('()' if isinstance(d, pdoc.Function) else '')) if not isinstance(d, pdoc.Doc) or isinstance(d, pdoc.External) and not external_links: return name url = d.url(relative_to=module, link_prefix=link_prefix, top_ancestor=not show_inherited_members) return '{}'.format(d.refname, url, name) def to_html(text): return _to_html(text, module=module, link=link, latex_math=latex_math) %> <%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: %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) %> <%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)) returns = show_type_annotations and f.return_annotation(link=link) or '' if returns: returns = ' ->\N{NBSP}' + returns %> ${f.funcdef()} ${ident(f.name)}(${params})${returns}
${show_desc(f)}
% if http_server: % endif

${'Namespace' if module.is_namespace else 'Module'} ${module.name}

${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:
var ${ident(v.name)}
${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:
var ${ident(v.name)}
${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:
var ${ident(v.name)}
${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: Python module list % else: ${module.name} API documentation % endif % if syntax_highlighting: %endif <%namespace name="css" file="css.mako" /> % if google_analytics: % endif % if latex_math: % endif <%include file="head.mako"/>
% if module_list:
${show_module_list(modules)}
% else:
${show_module(module)}
${module_index(module)} % endif
% if syntax_highlighting: % endif % if http_server and module: ## Auto-reload on file change in dev mode % endif