diff mbox

[v2,07/13] autodoc: add markup to argument's references

Message ID 20180519130602.90096-8-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck May 19, 2018, 1:05 p.m. UTC
The syntax for a parameter is '@<name>'. Let also use this when
referencing a parameter name in another section (other parameters
or long description) and mark these references in bold (the same
as the parameters themseelves are presented).

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Documentation/sphinx/cdoc.py | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/Documentation/sphinx/cdoc.py b/Documentation/sphinx/cdoc.py
index 7137b2a67..410a55ea2 100755
--- a/Documentation/sphinx/cdoc.py
+++ b/Documentation/sphinx/cdoc.py
@@ -183,6 +183,11 @@  def process_file(f):
 
 	return docs
 
+def decorate(l):
+	# type: (str) -> str
+	l = re.sub(r"@(\w+)", "**\\1**", l)
+	return l
+
 def convert_to_rst(info):
 	# type: (Dict[str, Any]) -> List[Tuple[int, str]]
 	lst = []
@@ -217,6 +222,7 @@  def convert_to_rst(info):
 			for (n, name, l) in info.get('tags', []):
 				if name != 'return':
 					name = 'param ' + name
+				l = decorate(l)
 				l = '\t:%s: %s' % (name, l)
 				lst.append((n, l))
 			lst.append((n+1, ''))
@@ -225,6 +231,7 @@  def convert_to_rst(info):
 			n = desc[0]
 			r = ''
 			for l in desc[1:]:
+				l = decorate(l)
 				r += '\t' + l + '\n'
 			lst.append((n, r))
 	return lst