nixos-render-docs: refactor option docs restrictions
move the restrictions we care about into a mixin class. a few more restrictions will appear soon and a few new converters as well, the renderers of which need not have these restrictions already baked in by accident (like the manpage renderer does right now).
This commit is contained in:
parent
45619b3c4a
commit
82d066ffe3
|
@ -171,7 +171,7 @@ class BaseConverter(Converter):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def finalize(self) -> str: raise NotImplementedError()
|
def finalize(self) -> str: raise NotImplementedError()
|
||||||
|
|
||||||
class OptionsDocBookRenderer(DocBookRenderer):
|
class OptionDocsRestrictions:
|
||||||
def heading_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
def heading_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||||
env: MutableMapping[str, Any]) -> str:
|
env: MutableMapping[str, Any]) -> str:
|
||||||
raise RuntimeError("md token not supported in options doc", token)
|
raise RuntimeError("md token not supported in options doc", token)
|
||||||
|
@ -179,6 +179,7 @@ class OptionsDocBookRenderer(DocBookRenderer):
|
||||||
env: MutableMapping[str, Any]) -> str:
|
env: MutableMapping[str, Any]) -> str:
|
||||||
raise RuntimeError("md token not supported in options doc", token)
|
raise RuntimeError("md token not supported in options doc", token)
|
||||||
|
|
||||||
|
class OptionsDocBookRenderer(OptionDocsRestrictions, DocBookRenderer):
|
||||||
# TODO keep optionsDocBook diff small. remove soon if rendering is still good.
|
# TODO keep optionsDocBook diff small. remove soon if rendering is still good.
|
||||||
def ordered_list_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
def ordered_list_open(self, token: Token, tokens: Sequence[Token], i: int, options: OptionsDict,
|
||||||
env: MutableMapping[str, Any]) -> str:
|
env: MutableMapping[str, Any]) -> str:
|
||||||
|
@ -287,7 +288,7 @@ class DocBookConverter(BaseConverter):
|
||||||
|
|
||||||
return "\n".join(result)
|
return "\n".join(result)
|
||||||
|
|
||||||
class OptionsManpageRenderer(ManpageRenderer):
|
class OptionsManpageRenderer(OptionDocsRestrictions, ManpageRenderer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ManpageConverter(BaseConverter):
|
class ManpageConverter(BaseConverter):
|
||||||
|
|
Loading…
Reference in a new issue