class documentation

class TemplateLookup:

View In Hierarchy

The TemplateLookup handles the HTML template files locations. A little bit like mako.lookup.TemplateLookup but more simple.

The location of the files depends wether the users set a template directory with the option --template-dir and/or with the option --theme, any files in a template directory will be loaded.

This object allow the customization of any templates.

For HTML templates, this can lead to warnings when upgrading pydoctor, then, please update your template from our repo.

See Also
Template, StaticTemplate, HtmlTemplate
Notes
The HTML templates versions are independent of the pydoctor version and are idependent from each other.
Template operations are case insensitive.
Method __init__ Loads all templates from the given path into the lookup.
Method add​_template Add a template to the lookup. The custom template override the default.
Method add​_templatedir Scan a directory and add all templates in the given directory to the lookup.
Method get​_loader Lookup a HTML template loader based on its filename.
Method get​_template Lookup a template based on its filename.
Property templates All templates that can be looked up. For each name, the custom template will be included if it exists, otherwise the default template.
Method ​_add​_overriding​_html​_template Undocumented
Method ​_raise​_if​_overrides​_directory Undocumented
Instance Variable ​_templates Undocumented
def __init__(self, path):
Loads all templates from the given path into the lookup.
Parameters
path:Union[Traversable, Path]A Path or Traversable object pointing to a directory to load the default set of templates from.
def add_template(self, template):

Add a template to the lookup. The custom template override the default.

If the file doesn't already exist in the lookup, we assume it is additional data used by the custom template.

For HTML, compare the new Template version with the currently loaded template, issue warnings if template are outdated.

Parameters
template:TemplateUndocumented
Raises
UnsupportedTemplateVersionIf the custom template is designed for a newer version of pydoctor.
OverrideTemplateNotAllowedIf this template path overrides a path of a different type (HTML/static/directory).
def add_templatedir(self, path):
Scan a directory and add all templates in the given directory to the lookup.
Parameters
path:Union[Path, Traversable]Undocumented
def get_loader(self, filename):
Lookup a HTML template loader based on its filename.
Parameters
filename:strUndocumented
Returns
ITemplateLoaderUndocumented
Raises
ValueErrorIf the template is not an HTML file.
def get_template(self, filename):

Lookup a template based on its filename.

Return the custom template if provided, else the default template.

Parameters
filename:strFile name, (ie 'index.html')
Returns
TemplateThe Template object
Raises
KeyErrorIf no template file is found with the given name
@property
templates: Iterable[Template] =
All templates that can be looked up. For each name, the custom template will be included if it exists, otherwise the default template.
def _add_overriding_html_template(self, template, current_template):

Undocumented

Parameters
template:HtmlTemplateUndocumented
current​_template:HtmlTemplateUndocumented
def _raise_if_overrides_directory(self, template_name):

Undocumented

Parameters
template​_name:strUndocumented
_templates: CaseInsensitiveDict[Template] =

Undocumented