diff options
author | David Sterba <dsterba@suse.com> | 2024-02-16 09:37:09 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-02-16 09:37:09 +0100 |
commit | 831a23616ab226e34cdc58278919fe16e447e3f9 (patch) | |
tree | 2f8f4279f29a6f39926eb4bc7cf0b6c889cf19fe | |
parent | 60abf7a90776c2405f616182ef6129474bbcb109 (diff) | |
download | btrfs-progs-831a23616ab226e34cdc58278919fe16e447e3f9.tar.gz |
btrfs-progs: docs: add role for manual page references
Add a new role to render manual page references and also link to the web
pages on man7.org.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | Documentation/conf.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Documentation/conf.py b/Documentation/conf.py index 014352ac..25896f5f 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -148,6 +148,26 @@ class DupLabelDirective(Directive): set_source_info(self, target_node) return [target_node] +# Manual page reference or link to man7.org +# Syntax: :manref:`page(1)` +# Backends: html, man +# - format is strict +# - html link target is not validated +def role_manref(name, rawtext, text, lineno, inliner, options={}, content=[]): + env = inliner.document.settings.env + name, number = text.split('(', 1) + number = number.split(')')[0] + + try: + ref_node = nodes.reference(text, f"{name}({number})", + refuri=f"https://man7.org/linux/man-pages/man{number}/{name}.{number}.html") + + except Exception as e: + inliner.reporter.warning(f"Error creating manref role: {str(e)}", line=lineno) + return [], [] + return [ref_node], [] + def setup(app): app.add_role('docref', role_docref) + app.add_role('manref', role_manref) app.add_directive('duplabel', DupLabelDirective) |