diff options
author | Tim Harder <radhermit@gmail.com> | 2021-01-04 06:37:01 -0700 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2021-01-04 08:44:08 -0700 |
commit | cc2dddb76ca12b8ba6c0a77768fa2173c9480509 (patch) | |
tree | c87968b10204e74c0f911909bb01adef17cbb416 | |
parent | ebuild.eclass: use full adornment for subtitle (diff) | |
download | pkgcore-cc2dddb76ca12b8ba6c0a77768fa2173c9480509.tar.gz pkgcore-cc2dddb76ca12b8ba6c0a77768fa2173c9480509.tar.bz2 pkgcore-cc2dddb76ca12b8ba6c0a77768fa2173c9480509.zip |
ebuild.eclass: inject some man page defaults into docutils
-rw-r--r-- | src/pkgcore/ebuild/eclass.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/pkgcore/ebuild/eclass.py b/src/pkgcore/ebuild/eclass.py index 6fa0ab10..c17bfe8c 100644 --- a/src/pkgcore/ebuild/eclass.py +++ b/src/pkgcore/ebuild/eclass.py @@ -4,12 +4,15 @@ import os import re import shlex import subprocess +from datetime import datetime from functools import partial from snakeoil import klass from snakeoil.mappings import ImmutableDict, OrderedSet from snakeoil.strings import pluralism +from snakeoil.version import get_version +from .. import __title__ from . import conditionals from .eapi import EAPI from ..log import logger @@ -566,7 +569,32 @@ class EclassDoc(AttrDict): def to_man(self): """Convert eclassdoc object to a man page.""" from docutils.writers import manpage - return self._to_docutils(manpage.Writer()) + + man_data = { + 'manual_section': '5', + 'manual_group': 'eclass-manpages', + 'date': datetime.utcnow().strftime('%Y-%m-%d'), + 'version': 'Gentoo Linux', + } + if self.blurb: + man_data['subtitle'] = self.blurb + + # add pkgcore version to header comment + pkgcore_version = get_version(__title__, __file__).split(' --')[0] + header_comment = f'\nCreated by {pkgcore_version}.' + + class Translator(manpage.Translator): + """Override docutils man page metadata defaults.""" + + document_start = manpage.Translator.document_start + header_comment + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._docinfo.update(man_data) + + writer = manpage.Writer() + writer.translator_class = Translator + return self._to_docutils(writer) def to_html(self): """Convert eclassdoc object to an HTML 5 document.""" |