Skip to content

Commit f4635bd

Browse files
committed
DOCSP-4705: emit <reference> uriref and uriname attributes
1 parent 3bdc0a7 commit f4635bd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

snooty/gizaparser/test_steps.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ def create_page() -> Tuple[Page, EmbeddedRstParser]:
4444
assert ast_to_testing_string(pages[0].ast) == ''.join((
4545
'<directive name="steps"><directive name="step"><section><heading><text>Import the public ',
4646
'key used by the package management system.</text></heading><paragraph><text>Issue the ',
47-
'following command to import the\n</text><reference><text>MongoDB public GPG Key</text>',
48-
'</reference><target ids="[\'mongodb-public-gpg-key\']"></target></paragraph></section>',
49-
'</directive>',
47+
'following command to import the\n</text><reference ',
48+
'refuri="https://www.mongodb.org/static/pgp/server-3.4.asc">',
49+
'<text>MongoDB public GPG Key</text>',
50+
'</reference><target ids="[\'mongodb-public-gpg-key\']" ',
51+
'refuri="https://www.mongodb.org/static/pgp/server-3.4.asc">',
52+
'</target></paragraph></section></directive>',
5053

5154
'<directive name="step"><section><heading><text>Create a </text><literal><text>',
5255
'/etc/apt/sources.list.d/mongodb-org-3.4.list</text></literal><text> file for MongoDB.',

snooty/parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
9494
elif node_name == 'target':
9595
doc['type'] = 'target'
9696
doc['ids'] = node['ids']
97+
if 'refuri' in node:
98+
doc['refuri'] = node['refuri']
9799
elif node_name == 'definition_list':
98100
doc['type'] = 'definitionList'
99101
elif node_name == 'definition_list_item':
@@ -109,6 +111,10 @@ def dispatch_visit(self, node: docutils.nodes.Node) -> None:
109111
doc['type'] = 'listItem'
110112
elif node_name == 'title':
111113
doc['type'] = 'heading'
114+
elif node_name == 'reference':
115+
for attr_name in ('refuri', 'refname'):
116+
if attr_name in node:
117+
doc[attr_name] = node[attr_name]
112118

113119
doc['children'] = []
114120

stubs/docutils/nodes.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Node:
2121

2222
def __getitem__(self, key: Union[int, str]) -> Any: ...
2323
def __setitem__(self, key: str, value: Any) -> None: ...
24+
def __contains__(self, key: str) -> bool: ...
2425

2526

2627
class Root: ...

0 commit comments

Comments
 (0)