Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a custom none role that is excluded from the output #32

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ This extension adds custom roles that can be used in rST.
Currently implemented:

- `spellexception` - Includes the provided text in `<spellexception></spellexception>`, which makes it possible to exclude it from a spelling checker.
- `monoref` - Renders the provided reference in code-style, which excludes the link text from the spelling checker.
You can provide either just the link (for example, ``:monoref:`www.example.com` ``, which results in `www.example.com` as the link text and `https://www.example.com` as the link URL) or a separate link text and URL (for example, ``:monoref:`xyzcommand <www.example.com>` ``).
- `literalref` - Renders the provided reference in code-style, which excludes the link text from the spelling checker.
You can provide either just the link (for example, ``:literalref:`www.example.com` ``, which results in `www.example.com` as the link text and `https://www.example.com` as the link URL) or a separate link text and URL (for example, ``:literalref:`xyzcommand <www.example.com>` ``).
- `none` - Excludes the provided text from the output.
This is useful for comments, especially when providing `wokeignore` rules.

### Config options

Expand Down
7 changes: 7 additions & 0 deletions canonical-sphinx-extensions/custom-rst-roles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def spellexception_role(
return [node], []


def none_role(
name, rawtext, text, lineno, inliner, options=None, content=None
):
return [], []


def literalref_role(
name, rawtext, text, lineno, inliner, options=None, content=None
):
Expand All @@ -37,5 +43,6 @@ def literalref_role(
def setup(app):
app.add_role("spellexception", spellexception_role)
app.add_role("literalref", literalref_role)
app.add_role("none", none_role)

return
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = canonical-sphinx-extensions
version = 0.0.17
version = 0.0.18
author = Ruth Fuchss
author_email = [email protected]
description = A collection of Sphinx extensions used by Canonical documentation
Expand Down