linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>, Jonathan Corbet <corbet@lwn.net>
Cc: "Daniel Vetter" <daniel@ffwll.ch>,
	"Linux Doc Mailing List" <linux-doc@vger.kernel.org>,
	"Mauro Carvalho Chehab" <mchehab@infradead.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Marc Zyngier" <marc.zyngier@arm.com>,
	"William Breathitt Gray" <vilhelm.gray@gmail.com>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	"Anil S Keshavamurthy" <anil.s.keshavamurthy@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Johannes Thumshirn" <morbidrsa@gmail.com>,
	"Steffen Klassert" <steffen.klassert@secunet.com>,
	"Sudip Mukherjee" <sudipm.mukherjee@gmail.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Rodolfo Giometti" <giometti@enneenne.com>,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Gustavo Padovan" <gustavo@padovan.org>,
	"Jens Wiklander" <jens.wiklander@linaro.org>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
	"David Airlie" <airlied@linux.ie>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <maxime.ripard@bootlin.com>,
	"Sean Paul" <sean@poorly.run>, "Farhan Ali" <alifm@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Heiko Carstens" <heiko.carstens@de.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Harry Wei" <harryxiyou@gmail.com>,
	"Alex Shi" <alex.shi@linux.alibaba.com>,
	"Evgeniy Polyakov" <zbr@ioremap.net>,
	"Jerry Hoemann" <jerry.hoemann@hpe.com>,
	"Wim Van Sebroeck" <wim@linux-watchdog.org>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Guan Xuetao" <gxt@pku.edu.cn>, "Arnd Bergmann" <arnd@arndb.de>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <bgolaszewski@baylibre.com>,
	"Andy Shevchenko" <andy@infradead.org>,
	"Jiri Slaby" <jslaby@suse.com>,
	linux-wireless@vger.kernel.org,
	"Linux PCI" <linux-pci@vger.kernel.org>,
	"open list:GENERIC INCLUDE/A..." <linux-arch@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org,
	"Kernel Hardening" <kernel-hardening@lists.openwall.com>,
	linux-remoteproc@vger.kernel.org,
	openipmi-developer@lists.sourceforge.net,
	linux-crypto@vger.kernel.org,
	"Linux ARM" <linux-arm-kernel@lists.infradead.org>,
	netdev <netdev@vger.kernel.org>,
	linux-pwm <linux-pwm@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	kvm@vger.kernel.org,
	"Linux Fbdev development list" <linux-fbdev@vger.kernel.org>,
	linux-s390@vger.kernel.org, linux-watchdog@vger.kernel.org,
	"moderated list:DMA BUFFER SHARING FRAMEWORK"
	<linaro-mm-sig@lists.linaro.org>,
	linux-gpio <linux-gpio@vger.kernel.org>,
	"Linux MM" <linux-mm@kvack.org>
Subject: Re: [PATCH v1 12/22] docs: driver-api: add .rst files from the main dir
Date: Wed, 19 Jun 2019 10:07:55 -0300	[thread overview]
Message-ID: <20190619075843.3c2464ac@coco.lan> (raw)
In-Reply-To: <20190619104239.GM3419@hirez.programming.kicks-ass.net>

Em Wed, 19 Jun 2019 12:42:39 +0200
Peter Zijlstra <peterz@infradead.org> escreveu:

> On Wed, Jun 19, 2019 at 07:22:18AM -0300, Mauro Carvalho Chehab wrote:
> > Hi Daniel,
> > 
> > Em Wed, 19 Jun 2019 11:05:57 +0200
> > Daniel Vetter <daniel@ffwll.ch> escreveu:
> >   
> > > On Tue, Jun 18, 2019 at 10:55 PM Mauro Carvalho Chehab
> > > <mchehab+samsung@kernel.org> wrote:  
> > > > diff --git a/Documentation/gpu/drm-mm.rst b/Documentation/gpu/drm-mm.rst
> > > > index fa30dfcfc3c8..b0f948d8733b 100644
> > > > --- a/Documentation/gpu/drm-mm.rst
> > > > +++ b/Documentation/gpu/drm-mm.rst
> > > > @@ -320,7 +320,7 @@ struct :c:type:`struct file_operations <file_operations>` get_unmapped_area
> > > >  field with a pointer on :c:func:`drm_gem_cma_get_unmapped_area`.
> > > >
> > > >  More detailed information about get_unmapped_area can be found in
> > > > -Documentation/nommu-mmap.rst
> > > > +Documentation/driver-api/nommu-mmap.rst    
> > > 
> > > Random drive-by comment: Could we convert these into hyperlinks within
> > > sphinx somehow, without making them less useful as raw file references
> > > (with vim I can just type 'gf' and it works, emacs probably the same).
> > > -Daniel  
> > 
> > Short answer: I don't know how vim/emacs would recognize Sphinx tags.  
> 
> 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().

Just did a test today at Jon's extension (with is currently on a
separate branch). At least the version that it is there at his automarkup
branch still needs some work, as it currently breaks titles and tables:

	6.4 :c:func:`resync_start()`, :c:func:`resync_finish()`
	-----------------------------------
	/devel/v4l/docs/Documentation/driver-api/md/md-cluster.rst:323: WARNING: Title underline too short.


	/devel/v4l/docs/Documentation/driver-api/serial/tty.rst:74: WARNING: Malformed table.
	Text in column margin in table line 34.

	======================= =======================================================
	:c:func:`open()`                        Called when the line discipline is attached to

-

That's said, once it gets fixed to address those complex cases, a
regex like:

	\bDocumentation/([\w\d\-\_\/]+)\.rst\b

could be converted to :doc: tag. It should be smart enough to convert
the relative paths, as we refer to the files from the git root directory
(with makes a lot sense to me), while Sphinx :doc: use relative patches
from the location where the parsed file is.

Something like the enclosed patch.

Thanks,
Mauro

[PATCH] automarkup.py: convert Documentation/* to hyperlinks

Auto-create hyperlinks when it finds a Documentation/.. occurrence.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py
index 39c8f4d5af82..9d6926b61241 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,17 @@ 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)
+
+            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.




  reply	other threads:[~2019-06-19 13:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1560890771.git.mchehab+samsung@kernel.org>
2019-06-18 20:53 ` Mauro Carvalho Chehab
2019-06-19  8:24   ` Thierry Reding
2019-06-19  9:05   ` Daniel Vetter
2019-06-19 10:22     ` Mauro Carvalho Chehab
2019-06-19 10:42       ` Peter Zijlstra
2019-06-19 13:07         ` Mauro Carvalho Chehab [this message]
2019-06-19 14:13         ` Jonathan Corbet
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:45     ` Peter Zijlstra
2019-06-19 11:50       ` Peter Zijlstra
2019-06-19 12:50   ` Andrea Parri
     [not found] <cover.1560891322.git.mchehab+samsung@kernel.org>
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=20190619075843.3c2464ac@coco.lan \
    --to=mchehab+samsung@kernel.org \
    --cc=afaerber@suse.de \
    --cc=airlied@linux.ie \
    --cc=alex.shi@linux.alibaba.com \
    --cc=alex.williamson@redhat.com \
    --cc=alifm@linux.ibm.com \
    --cc=andy@infradead.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=arnd@arndb.de \
    --cc=b.zolnierkie@samsung.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=davem@davemloft.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=farman@linux.ibm.com \
    --cc=giometti@enneenne.com \
    --cc=gor@linux.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@padovan.org \
    --cc=gxt@pku.edu.cn \
    --cc=harryxiyou@gmail.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jens.wiklander@linaro.org \
    --cc=jerry.hoemann@hpe.com \
    --cc=jslaby@suse.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=marc.zyngier@arm.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=mchehab@infradead.org \
    --cc=mhiramat@kernel.org \
    --cc=morbidrsa@gmail.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=pasic@linux.ibm.com \
    --cc=perex@perex.cz \
    --cc=peterz@infradead.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sean@poorly.run \
    --cc=steffen.klassert@secunet.com \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=sumit.semwal@linaro.org \
    --cc=thierry.reding@gmail.com \
    --cc=vilhelm.gray@gmail.com \
    --cc=wim@linux-watchdog.org \
    --cc=zbr@ioremap.net \
    /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