Skip to content

Commit 2916873

Browse files
MarkDaoustcopybara-github
authored andcommitted
Support double-backticks as delimiters.
PiperOrigin-RevId: 526769264
1 parent 0c78d6d commit 2916873

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tools/tensorflow_docs/api_generator/reference_resolver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ class ReferenceResolver:
7676
AUTO_REFERENCE_RE = re.compile(
7777
r"""
7878
(?P<brackets>\[.*?\])| # match a '[]' span
79-
`(?P<backticks>@?[\w\(\[\)\]\{\}.,=\s]+?)` # or a `` span
79+
``?(?P<backticks>@?[\w\(\[\)\]\{\}.,=\s]+?)``? # or a `` span
8080
""",
81-
flags=re.VERBOSE)
81+
flags=re.VERBOSE,
82+
)
8283

8384
def __init__(
8485
self,

tools/tensorflow_docs/api_generator/reference_resolver_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from tensorflow_docs.api_generator import reference_resolver as reference_resolver_lib
2929

3030

31-
3231
class TestReferenceResolver(absltest.TestCase):
3332
_BASE_DIR = tempfile.mkdtemp()
3433

@@ -113,6 +112,7 @@ class TestPartialSymbolAutoRef(parameterized.TestCase):
113112
('parens', 'Model.fit(x, y, epochs=5)', '../tf/keras/Model.md#fit'),
114113
('duplicate_name', 'tf.matmul', '../tf/linalg/matmul.md'),
115114
('full_name', 'tf.concat', '../tf/concat.md'),
115+
('extra_backticks', '`tf.concat`', '../tf/concat.md'),
116116
('normal_and_compat', 'linalg.matmul', '../tf/linalg/matmul.md'),
117117
('compat_only', 'math.deprecated', None),
118118
('contrib_only', 'y.z', None),
@@ -146,7 +146,7 @@ def test_partial_symbol_references(self, string, link):
146146
if link is None:
147147
expected = input_string
148148
else:
149-
expected = self.REF_TEMPLATE.format(link=link, text=string)
149+
expected = self.REF_TEMPLATE.format(link=link, text=string.strip('`'))
150150

151151
self.assertEqual(expected, ref_string)
152152

0 commit comments

Comments
 (0)