From: "Nícolas F. R. A. Prado" <nfraprado@protonmail.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Randy Dunlap <rdunlap@infradead.org>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Miguel Ojeda <ojeda@kernel.org>,
Andrew Klychkov <andrew.a.klychkov@gmail.com>,
lkcamp@lists.libreplanetbr.org, andrealmeid@collabora.com
Subject: [PATCH 1/2] docs: Enable usage of relative paths to docs on automarkup
Date: Thu, 28 Jan 2021 01:01:25 +0000 [thread overview]
Message-ID: <20210128010028.58541-2-nfraprado@protonmail.com> (raw)
In-Reply-To: <20210128010028.58541-1-nfraprado@protonmail.com>
Previously, a cross-reference to another document could only be created
by writing the full path to the document starting from the
Documentation/ directory.
Extend this to also allow relative paths to be used. A relative path
would be just the path, like ../filename.rst, while the absolute path
still needs to start from Documentation, like Documentation/filename.rst.
As part of this change, the .rst extension is now required for both
types of paths, since not requiring it would cause the regex to be too
generic.
Suggested-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com>
---
Documentation/sphinx/automarkup.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py
index 953b24b6e2b4..4b6aef9b35db 100644
--- a/Documentation/sphinx/automarkup.py
+++ b/Documentation/sphinx/automarkup.py
@@ -51,7 +51,7 @@ RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
# Detects a reference to a documentation page of the form Documentation/... with
# an optional extension
#
-RE_doc = re.compile(r'\bDocumentation(/[\w\-_/]+)(\.\w+)*')
+RE_doc = re.compile(r'(\bDocumentation/)?((\.\./)*[\w\-/]+)\.rst')
RE_namespace = re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$')
@@ -234,7 +234,10 @@ def markup_doc_ref(docname, app, match):
#
# Go through the dance of getting an xref out of the std domain
#
- target = match.group(1)
+ absolute = match.group(1)
+ target = match.group(2)
+ if absolute:
+ target = "/" + target
xref = None
pxref = addnodes.pending_xref('', refdomain = 'std', reftype = 'doc',
reftarget = target, modname = None,
--
2.30.0
next prev parent reply other threads:[~2021-01-28 1:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 1:01 [PATCH 0/2] docs: Add support for relative paths in automarkup Nícolas F. R. A. Prado
2021-01-28 1:01 ` Nícolas F. R. A. Prado [this message]
2021-01-28 1:01 ` [PATCH 2/2] docs: Document cross-referencing using relative path Nícolas F. R. A. Prado
2021-02-04 23:28 ` [PATCH 0/2] docs: Add support for relative paths in automarkup Jonathan Corbet
2021-02-04 23:48 ` Randy Dunlap
2021-02-04 23:53 ` Jonathan Corbet
2021-02-05 1:07 ` Nícolas F. R. A. Prado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210128010028.58541-2-nfraprado@protonmail.com \
--to=nfraprado@protonmail.com \
--cc=andrealmeid@collabora.com \
--cc=andrew.a.klychkov@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkcamp@lists.libreplanetbr.org \
--cc=mchehab+huawei@kernel.org \
--cc=ojeda@kernel.org \
--cc=rdunlap@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox