class documentation

Represents a pydoctor template file.

It holds references to template information.

It's an additionnal level of abstraction to hook to the writer class.

Use Template.fromfile or Template.fromdir to create Templates.

See Also
TemplateLookup, StaticTemplate and HtmlTemplate
Note

Directories are not Template. The Template.name attribute is the relative path to the template file, it may include subdirectories in it!

Currently, subdirectories should only contains static templates. This is because the subdirectory creation is handled in StaticTemplate.write().

Class Method fromdir Scan a directory for templates.
Class Method fromfile Create a concrete template object. Type depends on the file extension.
Method __init__ Undocumented
Instance Variable name Template filename, may include subdirectories.
@classmethod
def fromdir(cls, basedir: Traversable | Path, subdir: PurePath | None = None) -> Iterator[Template]: (source)

Scan a directory for templates.

Parameters
basedir:Traversable | PathA Path or Traversable object that should point to the root directory of the template directory structure.
subdir:PurePath | NoneThe subdirectory inside the template directory structure that we want to scan, relative to the basedir. Scan the basedir if None.
Returns
Iterator[Template]Undocumented
Raises
FailedToCreateTemplateIf the path is not a directory or do not exist.
@classmethod
def fromfile(cls, basedir: Traversable | Path, templatepath: PurePath) -> Template | None: (source)

Create a concrete template object. Type depends on the file extension.

Parameters
basedir:Traversable | PathA Path or Traversable object that should point to the root directory of the template directory structure.
templatepath:PurePathThe path to the template file, relative to the basedir.
Returns
Template | NoneThe template object or None if a the path entry is not a file.
Raises
FailedToCreateTemplateIf there is an error while creating the template.

Template filename, may include subdirectories.