From 724b410e915c53ba27ff5d6ca81e0b1b3fe6cb0a Mon Sep 17 00:00:00 2001 From: priya-sundaram-dev Date: Sat, 5 Sep 2026 18:40:14 +0000 Subject: [PATCH 1/2] Add a table of contents to DIRECTORY.md 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 #13239 / #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. --- DIRECTORY.md | 46 +++++++++++++++++++++++++++++++++++ scripts/build_directory_md.py | 31 ++++++++++++++++++++++- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index b59fed77f025..eb7a5c726dbb 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -1,3 +1,49 @@ +## Table of Contents +* [Audio Filters](#audio-filters) +* [Backtracking](#backtracking) +* [Bit Manipulation](#bit-manipulation) +* [Blockchain](#blockchain) +* [Boolean Algebra](#boolean-algebra) +* [Cellular Automata](#cellular-automata) +* [Ciphers](#ciphers) +* [Computer Vision](#computer-vision) +* [Conversions](#conversions) +* [Data Compression](#data-compression) +* [Data Structures](#data-structures) +* [Digital Image Processing](#digital-image-processing) +* [Divide And Conquer](#divide-and-conquer) +* [Docs](#docs) +* [Dynamic Programming](#dynamic-programming) +* [Electronics](#electronics) +* [File Transfer](#file-transfer) +* [Financial](#financial) +* [Fractals](#fractals) +* [Fuzzy Logic](#fuzzy-logic) +* [Genetic Algorithm](#genetic-algorithm) +* [Geodesy](#geodesy) +* [Geometry](#geometry) +* [Graphics](#graphics) +* [Graphs](#graphs) +* [Greedy Methods](#greedy-methods) +* [Hashes](#hashes) +* [Knapsack](#knapsack) +* [Linear Algebra](#linear-algebra) +* [Linear Programming](#linear-programming) +* [Machine Learning](#machine-learning) +* [Maths](#maths) +* [Matrix](#matrix) +* [Networking Flow](#networking-flow) +* [Neural Network](#neural-network) +* [Other](#other) +* [Physics](#physics) +* [Project Euler](#project-euler) +* [Quantum](#quantum) +* [Scheduling](#scheduling) +* [Searches](#searches) +* [Sorts](#sorts) +* [Strings](#strings) +* [Tests](#tests) +* [Web Programming](#web-programming) ## Audio Filters * [Butterworth Filter](audio_filters/butterworth_filter.py) diff --git a/scripts/build_directory_md.py b/scripts/build_directory_md.py index bdad7686c7e3..925c77a322a9 100755 --- a/scripts/build_directory_md.py +++ b/scripts/build_directory_md.py @@ -34,6 +34,21 @@ def md_prefix(indent: int) -> str: return f"{indent * ' '}*" if indent else "\n##" +def md_anchor(heading: str) -> str: + """ + GitHub-style anchor slug for a section heading, so the table of contents + can link to it. + + >>> md_anchor("Audio Filters") + 'audio-filters' + >>> md_anchor("Bit Manipulation") + 'bit-manipulation' + >>> md_anchor("Computer Vision") + 'computer-vision' + """ + return heading.strip().lower().replace(" ", "-") + + def print_path(old_path: str, new_path: str) -> str: old_parts = old_path.split(os.sep) for i, new_part in enumerate(new_path.split(os.sep)): @@ -43,8 +58,22 @@ def print_path(old_path: str, new_path: str) -> str: def print_directory_md(top_dir: str = ".") -> None: + filepaths = sorted(good_file_paths(top_dir)) + + # Top-level sections, in the order they appear, for the table of contents. + sections = list( + dict.fromkeys( + fp.split(os.sep)[0].replace("_", " ").title() + for fp in filepaths + if os.sep in fp + ) + ) + print("## Table of Contents") + for section in sections: + print(f"* [{section}](#{md_anchor(section)})") + old_path = "" - for filepath in sorted(good_file_paths(top_dir)): + for filepath in filepaths: filepath, filename = os.path.split(filepath) if filepath != old_path: old_path = print_path(old_path, filepath) From 06a807216a92fbb997c5c2cf54fa5d7d233b0194 Mon Sep 17 00:00:00 2001 From: Priya Sundaram Date: Sun, 6 Sep 2026 06:11:12 +0000 Subject: [PATCH 2/2] Address review: numbered ToC + link section headings to their directories - 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. --- DIRECTORY.md | 180 +++++++++++++++++----------------- scripts/build_directory_md.py | 15 ++- 2 files changed, 102 insertions(+), 93 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index eb7a5c726dbb..e3310d5305da 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -1,57 +1,57 @@ ## Table of Contents -* [Audio Filters](#audio-filters) -* [Backtracking](#backtracking) -* [Bit Manipulation](#bit-manipulation) -* [Blockchain](#blockchain) -* [Boolean Algebra](#boolean-algebra) -* [Cellular Automata](#cellular-automata) -* [Ciphers](#ciphers) -* [Computer Vision](#computer-vision) -* [Conversions](#conversions) -* [Data Compression](#data-compression) -* [Data Structures](#data-structures) -* [Digital Image Processing](#digital-image-processing) -* [Divide And Conquer](#divide-and-conquer) -* [Docs](#docs) -* [Dynamic Programming](#dynamic-programming) -* [Electronics](#electronics) -* [File Transfer](#file-transfer) -* [Financial](#financial) -* [Fractals](#fractals) -* [Fuzzy Logic](#fuzzy-logic) -* [Genetic Algorithm](#genetic-algorithm) -* [Geodesy](#geodesy) -* [Geometry](#geometry) -* [Graphics](#graphics) -* [Graphs](#graphs) -* [Greedy Methods](#greedy-methods) -* [Hashes](#hashes) -* [Knapsack](#knapsack) -* [Linear Algebra](#linear-algebra) -* [Linear Programming](#linear-programming) -* [Machine Learning](#machine-learning) -* [Maths](#maths) -* [Matrix](#matrix) -* [Networking Flow](#networking-flow) -* [Neural Network](#neural-network) -* [Other](#other) -* [Physics](#physics) -* [Project Euler](#project-euler) -* [Quantum](#quantum) -* [Scheduling](#scheduling) -* [Searches](#searches) -* [Sorts](#sorts) -* [Strings](#strings) -* [Tests](#tests) -* [Web Programming](#web-programming) +1. [Audio Filters](#audio-filters) +2. [Backtracking](#backtracking) +3. [Bit Manipulation](#bit-manipulation) +4. [Blockchain](#blockchain) +5. [Boolean Algebra](#boolean-algebra) +6. [Cellular Automata](#cellular-automata) +7. [Ciphers](#ciphers) +8. [Computer Vision](#computer-vision) +9. [Conversions](#conversions) +10. [Data Compression](#data-compression) +11. [Data Structures](#data-structures) +12. [Digital Image Processing](#digital-image-processing) +13. [Divide And Conquer](#divide-and-conquer) +14. [Docs](#docs) +15. [Dynamic Programming](#dynamic-programming) +16. [Electronics](#electronics) +17. [File Transfer](#file-transfer) +18. [Financial](#financial) +19. [Fractals](#fractals) +20. [Fuzzy Logic](#fuzzy-logic) +21. [Genetic Algorithm](#genetic-algorithm) +22. [Geodesy](#geodesy) +23. [Geometry](#geometry) +24. [Graphics](#graphics) +25. [Graphs](#graphs) +26. [Greedy Methods](#greedy-methods) +27. [Hashes](#hashes) +28. [Knapsack](#knapsack) +29. [Linear Algebra](#linear-algebra) +30. [Linear Programming](#linear-programming) +31. [Machine Learning](#machine-learning) +32. [Maths](#maths) +33. [Matrix](#matrix) +34. [Networking Flow](#networking-flow) +35. [Neural Network](#neural-network) +36. [Other](#other) +37. [Physics](#physics) +38. [Project Euler](#project-euler) +39. [Quantum](#quantum) +40. [Scheduling](#scheduling) +41. [Searches](#searches) +42. [Sorts](#sorts) +43. [Strings](#strings) +44. [Tests](#tests) +45. [Web Programming](#web-programming) -## Audio Filters +## [Audio Filters](audio_filters) * [Butterworth Filter](audio_filters/butterworth_filter.py) * [Equal Loudness Filter](audio_filters/equal_loudness_filter.py) * [Iir Filter](audio_filters/iir_filter.py) * [Show Response](audio_filters/show_response.py) -## Backtracking +## [Backtracking](backtracking) * [All Combinations](backtracking/all_combinations.py) * [All Permutations](backtracking/all_permutations.py) * [All Subsequences](backtracking/all_subsequences.py) @@ -74,7 +74,7 @@ * [Word Ladder](backtracking/word_ladder.py) * [Word Search](backtracking/word_search.py) -## Bit Manipulation +## [Bit Manipulation](bit_manipulation) * [Binary And Operator](bit_manipulation/binary_and_operator.py) * [Binary Coded Decimal](bit_manipulation/binary_coded_decimal.py) * [Binary Count Setbits](bit_manipulation/binary_count_setbits.py) @@ -102,10 +102,10 @@ * [Single Bit Manipulation Operations](bit_manipulation/single_bit_manipulation_operations.py) * [Swap All Odd And Even Bits](bit_manipulation/swap_all_odd_and_even_bits.py) -## Blockchain +## [Blockchain](blockchain) * [Diophantine Equation](blockchain/diophantine_equation.py) -## Boolean Algebra +## [Boolean Algebra](boolean_algebra) * [And Gate](boolean_algebra/and_gate.py) * [Imply Gate](boolean_algebra/imply_gate.py) * [Karnaugh Map Simplification](boolean_algebra/karnaugh_map_simplification.py) @@ -119,7 +119,7 @@ * [Xnor Gate](boolean_algebra/xnor_gate.py) * [Xor Gate](boolean_algebra/xor_gate.py) -## Cellular Automata +## [Cellular Automata](cellular_automata) * [Conways Game Of Life](cellular_automata/conways_game_of_life.py) * [Elementary Cellular Automaton](cellular_automata/elementary_cellular_automaton.py) * [Game Of Life](cellular_automata/game_of_life.py) @@ -128,7 +128,7 @@ * [One Dimensional](cellular_automata/one_dimensional.py) * [Wa Tor](cellular_automata/wa_tor.py) -## Ciphers +## [Ciphers](ciphers) * [A1Z26](ciphers/a1z26.py) * [Affine Cipher](ciphers/affine_cipher.py) * [Atbash](ciphers/atbash.py) @@ -177,7 +177,7 @@ * [Vigenere Cipher](ciphers/vigenere_cipher.py) * [Xor Cipher](ciphers/xor_cipher.py) -## Computer Vision +## [Computer Vision](computer_vision) * [Cnn Classification](computer_vision/cnn_classification.py) * [Flip Augmentation](computer_vision/flip_augmentation.py) * [Haralick Descriptors](computer_vision/haralick_descriptors.py) @@ -188,7 +188,7 @@ * [Mosaic Augmentation](computer_vision/mosaic_augmentation.py) * [Pooling Functions](computer_vision/pooling_functions.py) -## Conversions +## [Conversions](conversions) * [Astronomical Length Scale Conversion](conversions/astronomical_length_scale_conversion.py) * [Binary To Decimal](conversions/binary_to_decimal.py) * [Binary To Hexadecimal](conversions/binary_to_hexadecimal.py) @@ -221,7 +221,7 @@ * [Volume Conversions](conversions/volume_conversions.py) * [Weight Conversion](conversions/weight_conversion.py) -## Data Compression +## [Data Compression](data_compression) * [Burrows Wheeler](data_compression/burrows_wheeler.py) * [Coordinate Compression](data_compression/coordinate_compression.py) * [Huffman](data_compression/huffman.py) @@ -231,7 +231,7 @@ * [Peak Signal To Noise Ratio](data_compression/peak_signal_to_noise_ratio.py) * [Run Length Encoding](data_compression/run_length_encoding.py) -## Data Structures +## [Data Structures](data_structures) * Arrays * [Equilibrium Index In Array](data_structures/arrays/equilibrium_index_in_array.py) * [Find Triplets With 0 Sum](data_structures/arrays/find_triplets_with_0_sum.py) @@ -363,7 +363,7 @@ * [Radix Tree](data_structures/trie/radix_tree.py) * [Trie](data_structures/trie/trie.py) -## Digital Image Processing +## [Digital Image Processing](digital_image_processing) * [Change Brightness](digital_image_processing/change_brightness.py) * [Change Contrast](digital_image_processing/change_contrast.py) * [Convert To Negative](digital_image_processing/convert_to_negative.py) @@ -393,7 +393,7 @@ * [Sepia](digital_image_processing/sepia.py) * [Test Digital Image Processing](digital_image_processing/test_digital_image_processing.py) -## Divide And Conquer +## [Divide And Conquer](divide_and_conquer) * [Closest Pair Of Points](divide_and_conquer/closest_pair_of_points.py) * [Convex Hull](divide_and_conquer/convex_hull.py) * [Heaps Algorithm](divide_and_conquer/heaps_algorithm.py) @@ -407,10 +407,10 @@ * [Power](divide_and_conquer/power.py) * [Strassen Matrix Multiplication](divide_and_conquer/strassen_matrix_multiplication.py) -## Docs +## [Docs](docs) * [Conf](docs/conf.py) -## Dynamic Programming +## [Dynamic Programming](dynamic_programming) * [Abbreviation](dynamic_programming/abbreviation.py) * [All Construct](dynamic_programming/all_construct.py) * [Bitmask](dynamic_programming/bitmask.py) @@ -462,7 +462,7 @@ * [Wildcard Matching](dynamic_programming/wildcard_matching.py) * [Word Break](dynamic_programming/word_break.py) -## Electronics +## [Electronics](electronics) * [Apparent Power](electronics/apparent_power.py) * [Builtin Voltage](electronics/builtin_voltage.py) * [Capacitor Equivalence](electronics/capacitor_equivalence.py) @@ -485,13 +485,13 @@ * [Resonant Frequency](electronics/resonant_frequency.py) * [Wheatstone Bridge](electronics/wheatstone_bridge.py) -## File Transfer +## [File Transfer](file_transfer) * [Receive File](file_transfer/receive_file.py) * [Send File](file_transfer/send_file.py) * Tests * [Test Send File](file_transfer/tests/test_send_file.py) -## Financial +## [Financial](financial) * [Equated Monthly Installments](financial/equated_monthly_installments.py) * [Exponential Moving Average](financial/exponential_moving_average.py) * [Interest](financial/interest.py) @@ -501,7 +501,7 @@ * [Straight Line Depreciation](financial/straight_line_depreciation.py) * [Time And Half Pay](financial/time_and_half_pay.py) -## Fractals +## [Fractals](fractals) * [Barnsley Fern](fractals/barnsley_fern.py) * [Julia Sets](fractals/julia_sets.py) * [Koch Snowflake](fractals/koch_snowflake.py) @@ -510,18 +510,18 @@ * [Sierpinski Triangle](fractals/sierpinski_triangle.py) * [Vicsek](fractals/vicsek.py) -## Fuzzy Logic +## [Fuzzy Logic](fuzzy_logic) * [Fuzzy Operations](fuzzy_logic/fuzzy_operations.py) * [Fuzzy Set Operations](fuzzy_logic/fuzzy_set_operations.py) -## Genetic Algorithm +## [Genetic Algorithm](genetic_algorithm) * [Basic String](genetic_algorithm/basic_string.py) -## Geodesy +## [Geodesy](geodesy) * [Haversine Distance](geodesy/haversine_distance.py) * [Lamberts Ellipsoidal Distance](geodesy/lamberts_ellipsoidal_distance.py) -## Geometry +## [Geometry](geometry) * [Geometry](geometry/geometry.py) * [Graham Scan](geometry/graham_scan.py) * [Jarvis March](geometry/jarvis_march.py) @@ -531,13 +531,13 @@ * [Test Graham Scan](geometry/tests/test_graham_scan.py) * [Test Jarvis March](geometry/tests/test_jarvis_march.py) -## Graphics +## [Graphics](graphics) * [Bezier Curve](graphics/bezier_curve.py) * [Butterfly Pattern](graphics/butterfly_pattern.py) * [Digital Differential Analyzer Line](graphics/digital_differential_analyzer_line.py) * [Vector3 For 2D Rendering](graphics/vector3_for_2d_rendering.py) -## Graphs +## [Graphs](graphs) * [A Star](graphs/a_star.py) * [Ant Colony Optimization Algorithms](graphs/ant_colony_optimization_algorithms.py) * [Articulation Points](graphs/articulation_points.py) @@ -604,7 +604,7 @@ * [Test Min Spanning Tree Kruskal](graphs/tests/test_min_spanning_tree_kruskal.py) * [Test Min Spanning Tree Prim](graphs/tests/test_min_spanning_tree_prim.py) -## Greedy Methods +## [Greedy Methods](greedy_methods) * [Best Time To Buy And Sell Stock](greedy_methods/best_time_to_buy_and_sell_stock.py) * [Fractional Cover Problem](greedy_methods/fractional_cover_problem.py) * [Fractional Knapsack](greedy_methods/fractional_knapsack.py) @@ -615,7 +615,7 @@ * [Optimal Merge Pattern](greedy_methods/optimal_merge_pattern.py) * [Smallest Range](greedy_methods/smallest_range.py) -## Hashes +## [Hashes](hashes) * [Adler32](hashes/adler32.py) * [Chaos Machine](hashes/chaos_machine.py) * [Djb2](hashes/djb2.py) @@ -629,7 +629,7 @@ * [Sha1](hashes/sha1.py) * [Sha256](hashes/sha256.py) -## Knapsack +## [Knapsack](knapsack) * [Greedy Knapsack](knapsack/greedy_knapsack.py) * [Knapsack](knapsack/knapsack.py) * [Recursive Approach Knapsack](knapsack/recursive_approach_knapsack.py) @@ -637,7 +637,7 @@ * [Test Greedy Knapsack](knapsack/tests/test_greedy_knapsack.py) * [Test Knapsack](knapsack/tests/test_knapsack.py) -## Linear Algebra +## [Linear Algebra](linear_algebra) * [Gaussian Elimination](linear_algebra/gaussian_elimination.py) * [Jacobi Iteration Method](linear_algebra/jacobi_iteration_method.py) * [Lu Decomposition](linear_algebra/lu_decomposition.py) @@ -654,10 +654,10 @@ * [Test Linear Algebra](linear_algebra/src/test_linear_algebra.py) * [Transformations 2D](linear_algebra/src/transformations_2d.py) -## Linear Programming +## [Linear Programming](linear_programming) * [Simplex](linear_programming/simplex.py) -## Machine Learning +## [Machine Learning](machine_learning) * [Apriori Algorithm](machine_learning/apriori_algorithm.py) * [Astar](machine_learning/astar.py) * [Automatic Differentiation](machine_learning/automatic_differentiation.py) @@ -693,7 +693,7 @@ * [Xgboost Classifier](machine_learning/xgboost_classifier.py) * [Xgboost Regressor](machine_learning/xgboost_regressor.py) -## Maths +## [Maths](maths) * [Abs](maths/abs.py) * [Addition Without Arithmetic](maths/addition_without_arithmetic.py) * [Aliquot Sum](maths/aliquot_sum.py) @@ -872,7 +872,7 @@ * [Volume](maths/volume.py) * [Zellers Congruence](maths/zellers_congruence.py) -## Matrix +## [Matrix](matrix) * [Binary Search Matrix](matrix/binary_search_matrix.py) * [Count Islands In Matrix](matrix/count_islands_in_matrix.py) * [Count Negative Numbers In Sorted Matrix](matrix/count_negative_numbers_in_sorted_matrix.py) @@ -897,13 +897,13 @@ * [Test Matrix Operation](matrix/tests/test_matrix_operation.py) * [Validate Sudoku Board](matrix/validate_sudoku_board.py) -## Networking Flow +## [Networking Flow](networking_flow) * [Dinic](networking_flow/dinic.py) * [Ford Fulkerson](networking_flow/ford_fulkerson.py) * [Minimum Cut](networking_flow/minimum_cut.py) * [Push Relabel](networking_flow/push_relabel.py) -## Neural Network +## [Neural Network](neural_network) * Activation Functions * [Binary Step](neural_network/activation_functions/binary_step.py) * [Exponential Linear Unit](neural_network/activation_functions/exponential_linear_unit.py) @@ -922,7 +922,7 @@ * [Simple Neural Network](neural_network/simple_neural_network.py) * [Two Hidden Layers Neural Network](neural_network/two_hidden_layers_neural_network.py) -## Other +## [Other](other) * [Activity Selection](other/activity_selection.py) * [Alternative List Arrange](other/alternative_list_arrange.py) * [Bankers Algorithm](other/bankers_algorithm.py) @@ -951,7 +951,7 @@ * [Tower Of Hanoi](other/tower_of_hanoi.py) * [Word Search](other/word_search.py) -## Physics +## [Physics](physics) * [Altitude Pressure](physics/altitude_pressure.py) * [Archimedes Principle Of Buoyant Force](physics/archimedes_principle_of_buoyant_force.py) * [Basic Orbital Capture](physics/basic_orbital_capture.py) @@ -987,7 +987,7 @@ * [Speeds Of Gas Molecules](physics/speeds_of_gas_molecules.py) * [Terminal Velocity](physics/terminal_velocity.py) -## Project Euler +## [Project Euler](project_euler) * Problem 001 * [Sol1](project_euler/problem_001/sol1.py) * [Sol2](project_euler/problem_001/sol2.py) @@ -1297,10 +1297,10 @@ * Problem 800 * [Sol1](project_euler/problem_800/sol1.py) -## Quantum +## [Quantum](quantum) * [Q Fourier Transform](quantum/q_fourier_transform.py) -## Scheduling +## [Scheduling](scheduling) * [Cpuschedulingalgorithms](scheduling/cpuschedulingalgorithms.py) * [First Come First Served](scheduling/first_come_first_served.py) * [Highest Response Ratio Next](scheduling/highest_response_ratio_next.py) @@ -1311,7 +1311,7 @@ * [Round Robin](scheduling/round_robin.py) * [Shortest Job First](scheduling/shortest_job_first.py) -## Searches +## [Searches](searches) * [Binary Search](searches/binary_search.py) * [Binary Tree Traversal](searches/binary_tree_traversal.py) * [Double Linear Search](searches/double_linear_search.py) @@ -1330,7 +1330,7 @@ * [Tabu Search](searches/tabu_search.py) * [Ternary Search](searches/ternary_search.py) -## Sorts +## [Sorts](sorts) * [Bead Sort](sorts/bead_sort.py) * [Binary Insertion Sort](sorts/binary_insertion_sort.py) * [Bitonic Sort](sorts/bitonic_sort.py) @@ -1382,7 +1382,7 @@ * [Unknown Sort](sorts/unknown_sort.py) * [Wiggle Sort](sorts/wiggle_sort.py) -## Strings +## [Strings](strings) * [Aho Corasick](strings/aho_corasick.py) * [Alternative String Arrange](strings/alternative_string_arrange.py) * [Anagrams](strings/anagrams.py) @@ -1441,10 +1441,10 @@ * [Word Patterns](strings/word_patterns.py) * [Z Function](strings/z_function.py) -## Tests +## [Tests](tests) * [Test Sorts](tests/test_sorts.py) -## Web Programming +## [Web Programming](web_programming) * [Co2 Emission](web_programming/co2_emission.py) * [Covid Stats Via Xpath](web_programming/covid_stats_via_xpath.py) * [Crawl Google Results](web_programming/crawl_google_results.py) diff --git a/scripts/build_directory_md.py b/scripts/build_directory_md.py index 925c77a322a9..ef6213fd6d0f 100755 --- a/scripts/build_directory_md.py +++ b/scripts/build_directory_md.py @@ -53,7 +53,14 @@ def print_path(old_path: str, new_path: str) -> str: old_parts = old_path.split(os.sep) for i, new_part in enumerate(new_path.split(os.sep)): if (i + 1 > len(old_parts) or old_parts[i] != new_part) and new_part: - print(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}") + title = new_part.replace("_", " ").title() + if i == 0: + # Link each top-level section heading to its algorithm + # directory, so readers can click the title and jump straight + # to the folder (no leading pound sign, unlike the ToC links). + print(f"{md_prefix(i)} [{title}]({new_part})") + else: + print(f"{md_prefix(i)} {title}") return new_path @@ -69,8 +76,10 @@ def print_directory_md(top_dir: str = ".") -> None: ) ) print("## Table of Contents") - for section in sections: - print(f"* [{section}](#{md_anchor(section)})") + for index, section in enumerate(sections, start=1): + # Numbered list so the final number is the total count of algorithm + # folders, visible at a glance. + print(f"{index}. [{section}](#{md_anchor(section)})") old_path = "" for filepath in filepaths: