Welcome to jaraco.packaging documentation!¶
This module is a Sphinx plugin. Add jaraco.packaging.sphinx
to conf.py, and the setup hook does the rest.
>>> 'setup' in globals()
True
- class jaraco.packaging.sphinx.SidebarLinksDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)¶
Bases:
SphinxDirectiveDirective which adds a toctree to the sidebar containing links to the project home and PyPI repo.
- option_spec = {'caption': <function unchanged_required>, 'home': <function flag>, 'pypi': <function flag>, 'releases': <function flag>}¶
Mapping of option names to validator functions.
- run() list[only]¶
Create the installation node.
>>> from unittest.mock import MagicMock >>> directive = object.__new__(SidebarLinksDirective) >>> directive.state = MagicMock() >>> env = directive.state.document.settings.env >>> env.docname = env.config.master_doc = 'index' >>> env.config.source_url = 'https://github.com/foo/bar' >>> directive.options = {'releases': None} >>> directive.content = [] >>> directive.content_offset = 0 >>> len(directive.run()) # one 'only' node wrapping the toctree 1 >>> env.config.source_url = '' >>> from docutils.parsers.rst import DirectiveError >>> directive.run() Traceback (most recent call last): ... docutils.parsers.rst.DirectiveError
- jaraco.packaging.sphinx.add_package_url(app: Sphinx, pagename: object, templatename: object, context: MutableMapping[str, str], doctree: object) None¶
- jaraco.packaging.sphinx.load_config_from_setup(app: Sphinx, config: Config) None¶
Replace values in app.config from package metadata
>>> class MockConfig: ... pass >>> class MockApp: ... confdir = 'docs' >>> config = MockConfig() >>> load_config_from_setup(MockApp(), config) >>> config.source_url 'https://github.com/jaraco/jaraco.packaging'