Skip to content

Commit

Permalink
Merge pull request #803 from stan-dev/cross-link-index
Browse files Browse the repository at this point in the history
Add links to index on function definitions
  • Loading branch information
WardBrian authored Aug 6, 2024
2 parents 48e9943 + 26a4322 commit 5ae71eb
Show file tree
Hide file tree
Showing 5 changed files with 1,974 additions and 1,927 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ src/**/*.tex

# For the Mac (Finder metatdata files)
*.DS_Store

.luarc.json
8 changes: 4 additions & 4 deletions gen_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def make_index_mapping(sigs):

sha = hashlib.sha1(sig.encode("utf-8")).hexdigest()
link = f"{file}#index-entry-{sha}"
index[name].append((link, index_entry))
index[name].append((link, index_entry, file.replace(".qmd", ".html")))

return index

Expand All @@ -53,9 +53,9 @@ def write_index_page(index):
f.write(f"\n## {start.upper()}\n")

escaped_name = name.replace("\\", "\\\\").replace("*", "\\*")
f.write(f"**{escaped_name}**<a id=\"{escaped_name}\" class=\"index-fn\"></a>:\n\n")
for link, entry in sorted(links, key=lambda x: x[1].lower() + x[0]):
f.write(f" - [{entry}]({link})\n")
f.write(f"<a id='{escaped_name}' href='#{escaped_name}' class='anchored unlink'>**{escaped_name}**:</a>\n\n")
for link, entry, file in sorted(links, key=lambda x: x[1].lower() + x[2] + x[0]):
f.write(f" - <div class='index-container'>[{entry}]({link}) <span class='detail'>({file})</span></div>\n")
f.write("\n\n")


Expand Down
Loading

0 comments on commit 5ae71eb

Please sign in to comment.