Skip to content

Commit 21a0d3a

Browse files
committed
Sort algorithm ref docs by endpoint name
1 parent 7cb381e commit 21a0d3a

File tree

2 files changed

+246
-249
lines changed

2 files changed

+246
-249
lines changed

doc/sphinx/create_algorithms_rst.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
from pathlib import Path
44
from textwrap import dedent
5+
from typing import Any
56

67
root_dir = Path(__file__).parent
78

@@ -24,22 +25,34 @@
2425
)
2526
)
2627

28+
algo_sections: dict[str, list[str]] = {}
29+
2730
for function in functions:
2831
name, sig, ret_type = (
2932
function["function"]["name"],
3033
function["function"]["signature"],
3134
function["function"]["return_type"],
3235
)
33-
fw.write(f".. py:function:: {name}({sig}) -> {ret_type}\n\n")
36+
algo_lines = []
37+
38+
algo_lines.append(f".. py:function:: {name}({sig}) -> {ret_type}\n\n")
3439

3540
if "description" in function:
3641
description = function["description"].strip()
3742
for desc in description.split("\n"):
38-
fw.write(f" {desc}\n")
43+
algo_lines.append(f" {desc}\n")
3944

40-
fw.write("\n")
45+
algo_lines.append("\n")
4146

4247
if "deprecated" in function:
4348
version, message = function["deprecated"]["version"], function["deprecated"]["message"]
44-
fw.write(f".. deprecated:: {version}\n")
45-
fw.write(f" {message}\n\n")
49+
algo_lines.append(f".. deprecated:: {version}\n")
50+
algo_lines.append(f" {message}\n\n")
51+
52+
algo_sections[name] = algo_lines
53+
54+
# sort by name
55+
sorted_section = sorted(algo_sections.items(), key=lambda x: x[0])
56+
57+
for name, section in sorted_section:
58+
fw.writelines(section)

0 commit comments

Comments
 (0)