From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Peter Zijlstra <peterz@infradead.org>,
Linux Doc Mailing List <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 12/22] docs: driver-api: add .rst files from the main dir
Date: Wed, 19 Jun 2019 12:02:29 -0300 [thread overview]
Message-ID: <20190619120229.78ce6e07@coco.lan> (raw)
In-Reply-To: <20190619081353.75762028@lwn.net>
Hi Jon,
Em Wed, 19 Jun 2019 08:13:53 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:
> On Wed, 19 Jun 2019 12:42:39 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > No, the other way around, Sphinx can recognize local files and treat
> > them special. That way we keep the text readable.
> >
> > Same with that :c:func:'foo' crap, that needs to die, and Sphinx needs
> > to be taught about foo().
>
> I did a patch to make that latter part happen, but haven't been able to
> find the time to address the comments and get it out there. It definitely
> cleaned up the source files a lot and is worth doing. Will try to get
> back to it soon.
See my comment. Yeah, the :c:func:'foo' (the version you merged at the automarkup
branch) has currently a bug, when there's something like:
func()
======
or when func() is inside a table.
Solving the table case would be a lot better if the plugin could run the
existing table parser and only then handle the cross-reference replacements,
but I've no idea how flexible the Sphinx plugins can be.
>
> The local file links should be easy to do; we shouldn't need to add any
> markup for those.
Yeah, those are easy - except if someone adds a Documentation/* link
inside a table or inside a topic header.
Running a modified version of your tool shows just two new warnings:
Documentation/translations/ja_JP/howto.rst:176: WARNING: undefined label: :doc: (if the link has no caption the label must precede a section header)
Documentation/translations/zh_CN/process/submitting-drivers.rst:25: WARNING: unknown document: ../../../Documentation/translations/zh_CN/process/submitting-patches
The first one is because of this:
:Ref:`Documentation/process/kernel-docs.rst <kernel_docs>`
(my parser didn't consider upper-case tags - a simple fix at a regex should
fix this)
The second one is because the URL is wrong. It is pointing to:
Documentation/Documentation/translations/zh_CN/process/submitting-patches
at Chinese translation.
So, at least the way our documentation is, the plugin seems to be working
as expected.
As a reference, I'm enclosing the diff against your patch:
commit 6231d7456e87bd3e11f892709945887bd55a8a20 (docs/automarkup)
Author: Jonathan Corbet <corbet@lwn.net>
Date: Thu Apr 25 07:55:07 2019 -0600
Docs: An initial automarkup extension for sphinx
Rather than fill our text files with :c:func:`function()` syntax, just do
the markup via a hook into the sphinx build process. As is always the
case, the real problem is detecting the situations where this markup should
*not* be done.
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Thanks,
Mauro
-
diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py
index 39c8f4d5af82..60dad596c790 100644
--- a/Documentation/sphinx/automarkup.py
+++ b/Documentation/sphinx/automarkup.py
@@ -9,6 +9,7 @@
from __future__ import print_function
import re
import sphinx
+#import sys # Just for debug
#
# Regex nastiness. Of course.
@@ -31,10 +32,26 @@ RE_literal = re.compile(r'^(\s*)(.*::\s*|\.\.\s+code-block::.*)$')
#
RE_whitesp = re.compile(r'^(\s*)')
+#
+# Get a documentation reference
+#
+RE_doc_links = re.compile(r'\bDocumentation/([\w\d\-\_\/]+)\.rst\b')
+
+#
+# Doc link false-positives
+#
+RE_false_doc_links = re.compile(r':ref:`\s*Documentation/[\w\d\-\_\/]+\.rst')
+
def MangleFile(app, docname, text):
ret = [ ]
previous = ''
literal = False
+
+ rel_dir = ''
+
+ for depth in range(0, docname.count('/')):
+ rel_dir += "../"
+
for line in text[0].split('\n'):
#
# See if we might be ending a literal block, as denoted by
@@ -63,7 +80,18 @@ def MangleFile(app, docname, text):
# Normal line - perform substitutions.
#
else:
- ret.append(RE_function.sub(r'\1:c:func:`\2`\3', line))
+# new_line = RE_function.sub(r'\1:c:func:`\2`\3', line)
+ new_line = line
+
+ if not RE_false_doc_links.search(new_line):
+ new_line = RE_doc_links.sub(r':doc:`' + rel_dir + r'\1`', new_line)
+
+ # # Just for debug - should be removed on production
+ # if new_line != line:
+ # print ("===>" + new_line, file=sys.stderr)
+
+ ret.append(new_line)
+
#
# Might we be starting a literal block? If so make note of
# the fact.
next prev parent reply other threads:[~2019-06-19 15:02 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1560890771.git.mchehab+samsung@kernel.org>
2019-06-18 20:53 ` [PATCH v1 12/22] docs: driver-api: add .rst files from the main dir Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 00/29] Convert files to ReST - part 2 Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 01/29] docs: connector: convert to ReST and rename to connector.rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 02/29] docs: lcd-panel-cgram.txt: convert docs to ReST and rename to *.rst Mauro Carvalho Chehab
2019-06-18 21:14 ` Miguel Ojeda
2019-06-18 23:14 ` Mauro Carvalho Chehab
2019-06-20 8:37 ` Miguel Ojeda
2019-06-18 20:53 ` [PATCH v2 03/29] docs: lp855x-driver.txt: convert to ReST and move to kernel-api Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 04/29] docs: m68k: convert docs to ReST and rename to *.rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 05/29] docs: cma/debugfs.txt: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 06/29] docs: console.txt: " Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-21 13:48 ` Greg Kroah-Hartman
2019-06-21 13:48 ` Greg Kroah-Hartman
2019-06-21 13:48 ` Greg Kroah-Hartman
2019-06-18 20:53 ` [PATCH v2 07/29] docs: pti_intel_mid.txt: convert it to pti_intel_mid.rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 08/29] docs: early-userspace: convert docs to ReST and rename to *.rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [Intel-wired-lan] [PATCH v2 09/29] docs: driver-model: " Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-21 13:47 ` [Intel-wired-lan] " Greg Kroah-Hartman
2019-06-21 13:47 ` Greg Kroah-Hartman
2019-06-18 20:53 ` [PATCH v2 10/29] docs: arm: " Mauro Carvalho Chehab
2019-06-21 12:59 ` Corentin Labbe
2019-06-18 20:53 ` [PATCH v2 11/29] docs: memory-devices: convert ti-emif.txt to ReST Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 12/29] docs: xen-tpmfront.txt: convert it to .rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 13/29] docs: bus-devices: ti-gpmc.rst: convert it to ReST Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 14/29] docs: nvmem: convert docs to ReST and rename to *.rst Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 15/29] docs: phy: convert samsung-usb2.txt to ReST format Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 16/29] docs: rbtree.txt: fix Sphinx build warnings Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 17/29] docs: DMA-API-HOWTO.txt: fix an unmarked code block Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 18/29] docs: accounting: convert to ReST Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 19/29] docs: ia64: " Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 20/29] docs: leds: " Mauro Carvalho Chehab
2019-06-21 10:59 ` Pavel Machek
2019-06-18 20:53 ` [PATCH v2 21/29] docs: laptops: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 22/29] docs: iio: " Mauro Carvalho Chehab
2019-06-22 9:43 ` Jonathan Cameron
2019-06-18 20:53 ` [PATCH v2 23/29] docs: namespaces: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 24/29] docs: nfc: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 25/29] docs: md: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 26/29] docs: mtd: " Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 27/29] docs: nvdimm: " Mauro Carvalho Chehab
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 28/29] docs: xtensa: " Mauro Carvalho Chehab
2019-06-18 20:53 ` [PATCH v2 29/29] docs: mmc: " Mauro Carvalho Chehab
2019-06-19 8:24 ` [PATCH v1 12/22] docs: driver-api: add .rst files from the main dir Thierry Reding
2019-06-19 8:24 ` Thierry Reding
2019-06-19 9:05 ` Daniel Vetter
2019-06-19 9:05 ` Daniel Vetter
2019-06-19 10:22 ` Mauro Carvalho Chehab
2019-06-19 10:22 ` Mauro Carvalho Chehab
2019-06-19 10:42 ` Peter Zijlstra
2019-06-19 10:42 ` Peter Zijlstra
2019-06-19 13:04 ` Mauro Carvalho Chehab
2019-06-19 13:07 ` Mauro Carvalho Chehab
2019-06-19 13:07 ` Mauro Carvalho Chehab
2019-06-19 14:13 ` Jonathan Corbet
2019-06-19 14:13 ` Jonathan Corbet
2019-06-19 15:02 ` Mauro Carvalho Chehab [this message]
2019-06-19 13:39 ` David Howells
2019-06-19 14:15 ` Mauro Carvalho Chehab
2019-06-19 14:54 ` Jonathan Corbet
2019-06-19 15:52 ` Jani Nikula
2019-06-19 15:54 ` Mauro Carvalho Chehab
2019-06-19 11:43 ` Peter Zijlstra
2019-06-19 11:43 ` Peter Zijlstra
2019-06-19 11:45 ` Peter Zijlstra
2019-06-19 11:45 ` Peter Zijlstra
2019-06-19 11:50 ` Peter Zijlstra
2019-06-19 11:50 ` Peter Zijlstra
2019-06-19 12:13 ` Solar Designer
2019-06-19 13:24 ` Mauro Carvalho Chehab
2019-06-19 13:19 ` Mauro Carvalho Chehab
2019-06-19 21:27 ` Peter Zijlstra
2019-06-20 2:24 ` Mauro Carvalho Chehab
2019-06-19 12:50 ` Andrea Parri
2019-06-19 12:50 ` Andrea Parri
2019-06-18 21:05 [PATCH v1 00/22] Convert files to ReST - part 3 Mauro Carvalho Chehab
2019-06-18 21:05 ` [PATCH v1 12/22] docs: driver-api: add .rst files from the main dir Mauro Carvalho Chehab
2019-06-18 21:05 ` Mauro Carvalho Chehab
2019-06-18 21:05 ` Mauro Carvalho Chehab
2019-06-18 21:05 ` Mauro Carvalho Chehab
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=20190619120229.78ce6e07@coco.lan \
--to=mchehab+samsung@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.