-
-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Improve management commands documentation
- use different role for Weblate and Django commands - render Weblate commands with weblate prefix so that full command is show - add migrate documentation to cover differences from Django Fixes #9253
- Loading branch information
Showing
17 changed files
with
160 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,53 @@ | ||
"""Sphinx plugins for Weblate documentation.""" | ||
import re | ||
|
||
from docutils.nodes import literal | ||
from sphinx import addnodes | ||
from sphinx.domains.std import Cmdoption | ||
|
||
# RE for option descriptions without a '--' prefix | ||
simple_option_desc_re = re.compile(r"([-_a-zA-Z0-9]+)(\s*.*?)(?=,\s+(?:/|-|--)|$)") | ||
|
||
|
||
class WeblateCommandLiteral(literal): | ||
def __init__(self, rawsource="", text="", *children, **attributes): | ||
if not text: | ||
text = "weblate " | ||
super().__init__(rawsource, text, *children, **attributes) | ||
|
||
|
||
def setup(app): | ||
app.add_crossref_type( | ||
directivename="setting", rolename="setting", indextemplate="pair: %s; setting" | ||
) | ||
app.add_object_type( | ||
directivename="weblate-admin", | ||
rolename="wladmin", | ||
indextemplate="pair: %s; weblate admin command", | ||
parse_node=parse_weblate_admin_node, | ||
ref_nodeclass=WeblateCommandLiteral, | ||
) | ||
app.add_directive("weblate-admin-option", Cmdoption) | ||
app.add_object_type( | ||
directivename="django-admin", | ||
rolename="djadmin", | ||
indextemplate="pair: %s; weblate admin command", | ||
indextemplate="pair: %s; django-admin command", | ||
parse_node=parse_django_admin_node, | ||
) | ||
app.add_directive("django-admin-option", Cmdoption) | ||
|
||
|
||
def parse_django_admin_node(env, sig, signode): | ||
def parse_weblate_admin_node(env, sig, signode): | ||
command = sig.split(" ")[0] | ||
# Context for options | ||
env.ref_context["std:program"] = command | ||
title = f"weblate {sig}" | ||
signode += addnodes.desc_name(title, title) | ||
return command | ||
|
||
|
||
def parse_django_admin_node(env, sig, signode): | ||
command = sig.split(" ")[0] | ||
env.ref_context["std:program"] = command | ||
title = "django-admin %s" % sig | ||
signode += addnodes.desc_name(title, title) | ||
return command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.