Extension Configurationο
Install using pip:
pip install sphinx-readme
Add the extension to your conf.py
:
extensions = [
"sphinx_readme",
]
For an example of the minimum required configuration,
please see the sample conf.py
file
Mandatory conf.py
valuesο
html_context
ο
- html_contextο
A dictionary containing info about your repository (
html_context
)At minimum, the username and repository name must be specified
Please see HTML Context Settings to determine the correct dictionary keys for your hosting platform
- Type
Dict
html_baseurl
ο
- html_baseurlο
The base URL which points to the root of the HTML documentation (
html_baseurl
)- Type
str
readme_src_files
ο
- readme_src_filesο
An individual/list of
rst
source files to parse, or a dictionary of source files mapped to output filesImportant
Filepaths should be specified relative to the source directory and
output directory
- Type
Union[str, List]
readme_docs_url_type
ο
- readme_docs_url_typeο
The documentation source to link to when resolving
autodoc
cross-referencesMust be either
"code"
or"html"
"code"
: usessphinx.ext.linkcode
to replace references with links to highlighted source code
- Example
"html"
: replaces references with links to HTML documentation entries
- Example
Note
If set to
code
, non-external:attr:
cross-references will not be replaced with linksInstead, theyβll be replaced with
inline literals
or left as isPlease see
readme_replace_attrs
andreadme_inline_markup
Optional conf.py
valuesο
readme_out_dir
ο
- readme_out_dirο
Specifies the path of the directory to save generated
rst
files toThe value should be provided as either
An absolute path; or
A path relative to the source directory
- Type
Union[str, Path]
- Default
the root directory of your repository, via
get_repo_dir()
readme_replace_attrs
ο
- readme_replace_attrsο
Specifies if non-external attribute (
:attr:
) cross-references should be replacedβ¦
If
True
, the value ofreadme_docs_url_type
determines how replacements are made:"html"
: references are replaced with a link to the corresponding documentation entry
- Example
:attr:`icon_map`
would be replaced withicon_map
or icon_map, depending on the value ofreadme_inline_markup
"code"
: attributes are replaced with inline markup
- Example
:attr:`icon_map`
would be replaced withicon_map
Note
External attribute cross-references are always replaced with links to documentation
- Type
bool
- Default
True
readme_inline_markup
ο
readme_raw_directive
ο
- readme_raw_directiveο
Specifies if the
raw
directive is supported by the platform you intend to render the generated file onTip
GitHub supports the
raw
directivePyPi, GitLab, and BitBucket do not support the
raw
directive
If set to
False
,Admonitions will be replaced with the
list-table
directive instead of HTML tablesAll
raw
directives in the file will be removed
- Type
bool
- Default
True
readme_tags
ο
- readme_tagsο
Specifies tags to use when evaluating the
<expression>
argument ofonly
directivesTip
See
replace_only_directives()
for more detail- Type
List[str]
- Default
["readme"]
readme_include_directive
ο
- readme_include_directiveο
Specifies if
include
directives should be parsed (file content inserted) or removed- Type
bool
- Default
True
readme_admonition_icons
ο
- readme_admonition_iconsο
An optional mapping of admonition classes and their icons
If specified, will be used to update the
icon_map
(below)
- Type
Optional[Dict[str, str]]
- Default
{
'attention': 'ποΈ',
'caution': 'β οΈ',
'danger': 'β’',
'error': 'β',
'hint': 'π§ ',
'important': 'π’',
'note': 'π',
'tip': 'π‘',
'warning': 'π©',
'default': 'π'
}
readme_default_admonition_icon
ο
readme_rubric_heading
ο
- readme_rubric_headingο
The character to use when replacing
rubric
directives with section headersMust be one of the following valid section title adornment characters:
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
If not specified, rubrics will be replaced with bold text instead of a heading
- Type
str
- Default
bold inline markup (
**title**
)
readme_blob
ο
- readme_blobο
The repository blob to link to - any of
"head"
,"last_tag"
, or"{blob}"
"head"
: links to the most recent commit hash; if this commit is tagged, uses the tag instead"last_tag"
: links to the most recently tagged commit; if no tags exist, uses"head"
"{blob}"
: links to the specified blob, for example"master"
or"v2.0.1"
- Type
str
- Default
"head"
linkcode_resolve
ο
- linkcode_resolveο
A
linkcode_resolve()
function forsphinx.ext.linkcode
to use when resolving the target ofautodoc
cross-references- Type
Callable
- Default
return value of
get_linkcode_resolve()