Skip to content

Commit 468c056

Browse files
fweikertcopybara-github
authored andcommitted
Bazel DocGen: Fix rewriter.py to correctly rewrite yaml includes
PiperOrigin-RevId: 536336117 Change-Id: I8286f18e5e95c6c60ed03764c4cef3c6743ca488
1 parent 38682d2 commit 468c056

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

scripts/docs/rewriter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def _fix_md_metadata(content, version):
5151
return _MD_METADATA_PATTERN.sub(r"\1/versions/{}\2".format(version), content)
5252

5353

54-
_YAML_PATH_PATTERN = re.compile(r"((book_|image_)?path: ['\"]?)(/.*?)(['\"]?)$",
55-
re.MULTILINE)
54+
_YAML_PATH_PATTERN = re.compile(
55+
r"(((book_|image_)?path|include): ['\"]?)(/.*?)(['\"]?)$", re.MULTILINE
56+
)
5657

5758
_YAML_IGNORE_LIST = frozenset(
5859
["/", "/_project.yaml", "/versions/", "/versions/_toc.yaml"])
@@ -61,7 +62,7 @@ def _fix_md_metadata(content, version):
6162
def _fix_yaml_paths(content, version):
6263

6364
def sub(m):
64-
prefix, path, suffix = m.group(1, 3, 4)
65+
prefix, path, suffix = m.group(1, 4, 5)
6566
if path in _YAML_IGNORE_LIST:
6667
return m.group(0)
6768

scripts/docs/testdata/expected_output/_book.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ upper_tabs:
3333
path: /versions/
3434
- title: Update versions with Bazelisk
3535
path: /versions/6.6.6/versions/updating-bazel
36+
- title: Build encyclopedia
37+
include: /versions/6.6.6/reference/be/_toc.yaml

scripts/docs/testdata/input/_book.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ upper_tabs:
3333
path: /versions/
3434
- title: Update versions with Bazelisk
3535
path: /versions/updating-bazel
36+
- title: Build encyclopedia
37+
include: /reference/be/_toc.yaml

0 commit comments

Comments
 (0)