Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 7ee38d8

Browse files
dandhleetbpg
andauthored
fix: allow multiple/custom index pages to be used (#280)
* fix: allow custom index files * test: include non-cloud library * test: update goldens * fix: retrieve markdown files * test: fix non-cloud setting * test: remove unnecessary requirements * test: remove region tags * Update docfx_yaml/markdown_utils.py Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com> * test: update goldens with proper region tags * fix: apply review suggestions --------- Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com>
1 parent 2221b48 commit 7ee38d8

51 files changed

Lines changed: 8173 additions & 10 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docfx_yaml/markdown_utils.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,16 @@ def move_markdown_pages(
301301
# Used to keep track of the index page entry to insert later.
302302
index_page_entry = None
303303

304+
markdown_file_names = {
305+
mdfile.name.lower()
306+
for mdfile in markdown_dir.iterdir()
307+
}
308+
309+
# If there is an index.md and no readme.md, use the index.md. Otherwise, we ignore the index.md.
310+
if ("index.md" in markdown_file_names and
311+
"readme.md" not in markdown_file_names):
312+
files_to_ignore.remove("index.md")
313+
304314
# For each file, if it is a markdown file move to the top level pages.
305315
for mdfile in markdown_dir.iterdir():
306316
if mdfile.is_dir():
@@ -332,6 +342,9 @@ def move_markdown_pages(
332342
if mdfile_name_to_use in files_to_rename:
333343
mdfile_name_to_use = files_to_rename[mdfile_name_to_use]
334344

345+
if cwd and mdfile_name_to_use == "index.md":
346+
mdfile_name_to_use = f"{'_'.join(cwd)}_{mdfile_name_to_use}"
347+
335348
mdfile_outdir = f"{outdir}/{mdfile_name_to_use}"
336349

337350
shutil.copy(mdfile, mdfile_outdir)
@@ -340,16 +353,16 @@ def move_markdown_pages(
340353
_highlight_md_codeblocks(mdfile_outdir)
341354
_clean_image_links(mdfile_outdir)
342355

343-
# Use Overview as the name for index file.
344-
if mdfile_name_to_use == 'index.md':
345-
# Save the index page entry.
346-
index_page_entry = {
347-
'name': 'Overview',
348-
'href': 'index.md',
349-
}
350-
continue
351-
352356
if not cwd:
357+
# Use Overview as the name for top-level index file.
358+
if 'index.md' in mdfile_name_to_use:
359+
# Save the index page entry.
360+
index_page_entry = {
361+
'name': 'Overview',
362+
'href': 'index.md',
363+
}
364+
continue
365+
353366
# Use '/' to reserve for top level pages.
354367
app.env.markdown_pages['/'].append({
355368
'name': name,

tests/test_goldens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
@pytest.mark.parametrize(
30-
"test_dir", ["handwritten", "gapic-combo", "gapic-auto"]
30+
"test_dir", ["handwritten", "gapic-combo", "gapic-auto", "non-cloud"]
3131
)
3232
def test_goldens(update_goldens, test_dir):
3333
source_dir = Path("tests/testdata") / test_dir

tests/testdata/goldens/non-cloud/api.md

Lines changed: 437 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)