deepmodeling_sphinx

pip install Documentation Status

This package should be used in all sphinx projects under the @deepmodeling organization.

Features

  • Add the DeepModeling banner

  • Add the ICP number to the footer

  • Minify HTML, Javascript, and CSS files

  • Supports dark mode for both the banner and the RTD theme

How to use it

Setup

Add deepmodeling_sphinx to the requirements, as well as the extensions of conf.py:

extensions = [
    'deepmodeling_sphinx',
]

Projects outside DeepModeling can also use this extension but disable DeepModeling specific styles.

# default: True
enable_deepmodeling = False

Render list of authors

The following directive can be used to render list of authors from git shortlog:

.. git-shortlog-authors::

Others

API

deepmodeling_sphinx package

deepmodeling_sphinx.setup(app: Sphinx) Dict[str, Any][source]

Submodules

deepmodeling_sphinx.authors module

A directive to list all authors from git-shortlog.

class deepmodeling_sphinx.authors.AuthorsDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]

Bases: SphinxDirective

authors directive.

Attributes:
config

Reference to the Config object.

env

Reference to the BuildEnvironment object.

Methods

add_name(node)

Append self.options['name'] to node['names'] if it exists.

assert_has_content()

Throw an ERROR-level DirectiveError if the directive doesn't have contents.

directive_error(level, message)

Return a DirectiveError suitable for being thrown as an exception.

get_location()

Get current location info for logging.

get_source_info()

Get source and line number.

run()

Run directive.

set_source_info(node)

Set source and line number to the node.

debug

error

info

severe

warning

has_content = False

May the directive have content?

option_spec = {}

Mapping of option names to validator functions.

run()[source]

Run directive.

deepmodeling_sphinx.authors.get_authors() Iterator[str][source]

Yields authors from git-shortlog.

Yields:
str

Author name.

deepmodeling_sphinx.authors.git_shortlog() str[source]

Return git-shortlog output as a string.

Returns:
str

Git-shortlog output.

deepmodeling_sphinx.authors.setup(app: Sphinx) Dict[str, Any][source]

deepmodeling_sphinx.config module

deepmodeling_sphinx.inject module

deepmodeling_sphinx.inject.copy_custom_files(app)[source]
deepmodeling_sphinx.inject.enable_dark_mode(app, config)[source]

Enable dark mode if the theme is sphinx_rtd_theme.

deepmodeling_sphinx.inject.insert_icp(app, pagename, templatename, context, doctree)[source]
deepmodeling_sphinx.inject.insert_sidebar(app, pagename, templatename, context, doctree)[source]
deepmodeling_sphinx.inject.minify_css_files(app, exception)[source]
deepmodeling_sphinx.inject.minify_html_files(app, pagename, templatename, context, doctree)[source]
deepmodeling_sphinx.inject.minify_js_files(app, exception)[source]
deepmodeling_sphinx.inject.render_banner(current_site='Docs') str[source]

Use jinja2 to render banner.

Returns:
str

HTML content of banner.

deepmodeling_sphinx.inject.setup(app: Sphinx) Dict[str, Any][source]

Authors

  • Chun Cai

  • JX278

  • Jinzhe Zeng

  • Yifan Li李一帆

  • pre-commit-ci[bot]