Skip to content

Commit 63d6ddf

Browse files
authored
Merging from Dev (#79)
* Refactor workflow step registration to avoid decorator ordering issues * Add self-loop handling in max flow calculation and extend tests for edge cases * Add self-loop handling in flow calculations and extend tests for edge cases * Implement overlapping node handling in max flow calculations and add comprehensive tests for pairwise mode scenarios * Add configuration for traffic manager and update estimation logic - Introduced TrafficManagerConfig class to manage traffic demand placement settings. - Updated default rounds handling in TrafficManager to use configuration values. - Added tests for configuration defaults and estimation logic. * Add configurable iteration limits to FlowPolicy and enhance infinite loop detection * Refactor api doc autogeneration * additional max_flow functionality in network.py * Add detailed max flow methods to API documentation * Update version to 0.7.1
1 parent e249779 commit 63d6ddf

29 files changed

+5530
-1285
lines changed

dev/generate_api_docs.py

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import argparse
1111
import dataclasses
12+
import glob
1213
import importlib
1314
import inspect
1415
import os
@@ -21,6 +22,57 @@
2122
sys.path.insert(0, ".")
2223

2324

25+
def discover_modules():
26+
"""Automatically discover all documentable Python modules in the ngraph package."""
27+
modules = []
28+
29+
# Find all .py files in ngraph/
30+
for py_file in glob.glob("ngraph/**/*.py", recursive=True):
31+
# Skip files that shouldn't be documented
32+
filename = os.path.basename(py_file)
33+
if filename in ["__init__.py", "__main__.py"]:
34+
continue
35+
36+
# Convert file path to module name
37+
module_path = py_file.replace("/", ".").replace(".py", "")
38+
modules.append(module_path)
39+
40+
# Sort modules in logical order for documentation
41+
def module_sort_key(module_name):
42+
"""Sort key to organize modules logically."""
43+
parts = module_name.split(".")
44+
45+
# Main ngraph modules first
46+
if len(parts) == 2: # ngraph.xxx
47+
return (0, parts[1])
48+
49+
# Then lib modules
50+
elif len(parts) == 3 and parts[1] == "lib": # ngraph.lib.xxx
51+
return (1, parts[2])
52+
53+
# Then algorithm modules
54+
elif len(parts) == 4 and parts[1:3] == [
55+
"lib",
56+
"algorithms",
57+
]: # ngraph.lib.algorithms.xxx
58+
return (2, parts[3])
59+
60+
# Then workflow modules
61+
elif len(parts) == 3 and parts[1] == "workflow": # ngraph.workflow.xxx
62+
return (3, parts[2])
63+
64+
# Then transform modules
65+
elif len(parts) == 3 and parts[1] == "transform": # ngraph.transform.xxx
66+
return (4, parts[2])
67+
68+
# Everything else at the end
69+
else:
70+
return (9, module_name)
71+
72+
modules.sort(key=module_sort_key)
73+
return modules
74+
75+
2476
def get_class_info(cls):
2577
"""Extract comprehensive information about a class."""
2678
info = {
@@ -160,30 +212,10 @@ def generate_api_documentation(output_to_file=False):
160212
str: The generated documentation (when output_to_file=False)
161213
"""
162214

163-
# Modules to document (in order)
164-
modules = [
165-
"ngraph.scenario",
166-
"ngraph.network",
167-
"ngraph.explorer",
168-
"ngraph.components",
169-
"ngraph.blueprints",
170-
"ngraph.traffic_demand",
171-
"ngraph.failure_policy",
172-
"ngraph.failure_manager",
173-
"ngraph.traffic_manager",
174-
"ngraph.results",
175-
"ngraph.lib.graph",
176-
"ngraph.lib.util",
177-
"ngraph.lib.algorithms.spf",
178-
"ngraph.lib.algorithms.max_flow",
179-
"ngraph.lib.algorithms.base",
180-
"ngraph.workflow.base",
181-
"ngraph.workflow.build_graph",
182-
"ngraph.workflow.capacity_probe",
183-
"ngraph.transform.base",
184-
"ngraph.transform.enable_nodes",
185-
"ngraph.transform.distribute_external",
186-
]
215+
# Automatically discover all documentable modules
216+
modules = discover_modules()
217+
218+
print(f"🔍 Auto-discovered {len(modules)} modules to document...")
187219

188220
# Generate header
189221
timestamp = datetime.now().strftime("%B %d, %Y at %H:%M UTC")
@@ -201,11 +233,13 @@ def generate_api_documentation(output_to_file=False):
201233
202234
**Generated from source code on:** {timestamp}
203235
236+
**Modules auto-discovered:** {len(modules)}
237+
204238
---
205239
206240
"""
207241

208-
print("🔍 Generating API documentation...")
242+
print("📝 Generating API documentation...")
209243
doc = header
210244

211245
# Generate documentation for each module

0 commit comments

Comments
 (0)