Skip to content

Add a table of contents to DIRECTORY.md - #15198

Merged
cclauss merged 2 commits into
TheAlgorithms:masterfrom
priya-sundaram-dev:feat/directory-md-table-of-contents
Sep 6, 2026
Merged

Add a table of contents to DIRECTORY.md#15198
cclauss merged 2 commits into
TheAlgorithms:masterfrom
priya-sundaram-dev:feat/directory-md-table-of-contents

Conversation

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor

Describe your change:

Adds a linked Table of Contents of the top-level sections to the top of DIRECTORY.md, so readers can jump straight to a category (Sorts, Graphs, Ciphers, …) instead of scrolling.

This is the auto-generated version of the idea in #13239 — rather than hand-editing DIRECTORY.md (which is overwritten by the directory writer), the ToC is produced by scripts/build_directory_md.py, so it stays in sync automatically. Thanks @cclauss for pointing to the right place.

Details:

  • New md_anchor() helper turns a section heading into a GitHub-style anchor slug, with doctests.
  • print_directory_md() first emits ## Table of Contents with one * [Section](#anchor) link per top-level section (order preserved), then the existing listing — no lines removed, purely additive.
  • DIRECTORY.md regenerated to match.

Closes #13111

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. (Tooling/docs change requested by a maintainer; touches scripts/build_directory_md.py and its generated output DIRECTORY.md.)
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation. (N/A — build tooling, not an algorithm.)
  • If this pull request resolves one issue, please mention that issue number.

Generate a linked table of contents of the top-level sections at the top
of DIRECTORY.md so readers can jump straight to a category, as suggested
in TheAlgorithms#13239 / TheAlgorithms#13111. The list is built in scripts/build_directory_md.py
(with a new md_anchor helper + doctests) so DIRECTORY.md stays fully
auto-generated.
@priya-sundaram-dev priya-sundaram-dev mentioned this pull request Sep 5, 2026
11 tasks
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Sep 5, 2026
@cclauss

cclauss commented Sep 6, 2026

Copy link
Copy Markdown
Member

This is great, but can you make the table of contents a numbered list so we can see at a glance how many algorithm folders we have? Also, can you please add a similar link, but without the pound sign, to each section title? When I am scrolling through the sections and I see one that I want to explore, I can click the section title and jump right to the algorithm directory.

…ries

- Table of Contents is now a numbered list, so the final number shows the
  total count of algorithm folders at a glance.
- Each top-level section heading links to its algorithm directory (e.g.
  ## [Sorts](sorts)), so clicking a section title jumps straight to the folder.
@priya-sundaram-dev

Copy link
Copy Markdown
Contributor Author

Thanks @cclauss — both done in build_directory_md.py so they stay auto-generated:

  1. Numbered ToC — the Table of Contents is now a numbered list (1., 2., …), so the last number is the total count of algorithm folders at a glance (currently 45).
  2. Clickable section titles — each top-level heading now links to its directory, e.g. ## [Sorts](sorts), so you can click a section title while scrolling and jump straight to that algorithm folder. The ToC anchor links (#sorts) are unchanged and still resolve, since GitHub builds the heading anchor from the link text.

DIRECTORY.md regenerated; the only content changes are the ToC format and the heading links (no entries added or removed). Doctests pass.

@cclauss cclauss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 6, 2026
@cclauss
cclauss merged commit 0c7ac7f into TheAlgorithms:master Sep 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement of readme document

2 participants