Skip to content

Commit 6b157a0

Browse files
Replace custom API doc extractors with numpydoc and Doxygen
Python API: keep AST walking (no imports needed) but pipe docstrings through numpydoc.docscrape.NumpyDocString, giving properly structured Parameters / Returns / Raises / Examples sections in the generated MDX. C API: replace fragile regex header parser with Doxygen XML pipeline. Doxyfile targets the two public headers; XML is parsed with ElementTree and rendered to MDX. Picks up 211 symbols vs ~80 before, handles @PARAM, @return, @brief, and enum values correctly. Add numpydoc to requirements-docs.txt and dependencies.yaml docs group. Add doxygen to dependencies.yaml docs group. Gitignore cpp/build_split/ and fern/.doxygen-xml/ build directories. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3c42477 commit 6b157a0

11 files changed

Lines changed: 846 additions & 1075 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ datasets/**
4545
## Doxygen
4646
cpp/doxygen/html
4747
cpp/doxygen/xml
48+
fern/.doxygen-xml/
4849

4950
# Jupyter Notebooks
5051
.ipynb_checkpoints
@@ -80,3 +81,4 @@ cpp/include/cuopt/semantic_version.hpp
8081

8182
# conda env (recommended name)
8283
.cuopt_env
84+
cpp/build_split/

dependencies.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,9 @@ dependencies:
789789
- jq
790790
- nodejs # provides npm; used to install fern-api CLI
791791
- *pyyaml
792+
- *doxygen
792793
- fastapi
794+
- numpydoc
793795
- pydantic
794796

795797
notebooks:

fern/Doxyfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Doxyfile for fern/extract_c_api.py
2+
# Processes the two cuOpt C API headers and outputs XML only.
3+
# Run from the repo root: doxygen fern/Doxyfile
4+
# XML is written to fern/.doxygen-xml/ (git-ignored).
5+
6+
DOXYFILE_ENCODING = UTF-8
7+
PROJECT_NAME = "cuOpt C API"
8+
PROJECT_BRIEF = "NVIDIA cuOpt C API reference"
9+
OUTPUT_DIRECTORY = fern/.doxygen-xml
10+
CREATE_SUBDIRS = NO
11+
OUTPUT_LANGUAGE = English
12+
FULL_PATH_NAMES = NO
13+
MARKDOWN_SUPPORT = YES
14+
EXTENSION_MAPPING = h=C
15+
OPTIMIZE_OUTPUT_FOR_C = YES
16+
17+
EXTRACT_ALL = YES
18+
EXTRACT_PRIVATE = NO
19+
EXTRACT_STATIC = NO
20+
21+
INPUT = cpp/include/cuopt/mathematical_optimization/cuopt_c.h \
22+
cpp/include/cuopt/mathematical_optimization/constants.h
23+
24+
INPUT_ENCODING = UTF-8
25+
FILE_PATTERNS = *.h
26+
RECURSIVE = NO
27+
28+
ENABLE_PREPROCESSING = YES
29+
MACRO_EXPANSION = YES
30+
EXPAND_ONLY_PREDEF = NO
31+
SKIP_FUNCTION_MACROS = YES
32+
33+
GENERATE_HTML = NO
34+
GENERATE_LATEX = NO
35+
GENERATE_XML = YES
36+
XML_OUTPUT = xml
37+
XML_PROGRAMLISTING = NO
38+
39+
QUIET = YES
40+
WARNINGS = YES
41+
WARN_IF_UNDOCUMENTED = NO

fern/docs/pages/cuopt-c/convex/convex-c-api.mdx

Lines changed: 132 additions & 168 deletions
Large diffs are not rendered by default.

fern/docs/pages/cuopt-c/mip/mip-c-api.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ For MIP problems, one or more primal solution hints (MIP starts) may be provided
1212

1313
<hr />
1414

15-
#### `cuOptAddMIPStart(cuOptSolverSettings settings, const cuopt_float_t* solution, cuopt_int_t num_variables) -> cuopt_int_t`
15+
#### `cuOptAddMIPStart(cuOptSolverSettings settings, const cuopt_float_t * solution, cuopt_int_t num_variables) -> cuopt_int_t`
1616

17-
Add an initial solution (MIP start) for MIP solving. This function can be called multiple times to add multiple MIP starts. The solver will use these as starting points for the MIP search.
17+
Add an initial solution (MIP start) for MIP solving.
1818

1919
<Note>
2020
Currently unsupported with presolve on. All pointer arguments (solution) refer to host memory.
@@ -23,7 +23,7 @@ Currently unsupported with presolve on. All pointer arguments (solution) refer t
2323
**Parameters**
2424

2525
- **`settings`** (`cuOptSolverSettings`) `[in]` — The solver settings object.
26-
- **`solution`** (`const cuopt_float_t*`) `[in]` — A pointer to an array of type cuopt_float_t of size num_variables containing the solution values.
26+
- **`solution`** (`const cuopt_float_t *`) `[in]` — A pointer to an array of type cuopt_float_t of size num_variables containing the solution values.
2727
- **`num_variables`** (`cuopt_int_t`) `[in]` — The number of variables (size of the solution array).
2828

2929
**Returns** A status code indicating success or failure.
@@ -64,7 +64,7 @@ All pointer arguments (solution, objective_value, solution_bound, user_data) ref
6464

6565
<hr />
6666

67-
#### `cuOptSetMIPGetSolutionCallback(cuOptSolverSettings settings, cuOptMIPGetSolutionCallback callback, void* user_data) -> cuopt_int_t`
67+
#### `cuOptSetMIPGetSolutionCallback(cuOptSolverSettings settings, cuOptMIPGetSolutionCallback callback, void * user_data) -> cuopt_int_t`
6868

6969
Register a callback to receive incumbent MIP solutions.
7070

@@ -76,13 +76,13 @@ The callback arguments refer to host memory and are only valid during the callba
7676

7777
- **`settings`** (`cuOptSolverSettings`) `[in]` — The solver settings object.
7878
- **`callback`** (`cuOptMIPGetSolutionCallback`) `[in]` — Callback function to receive incumbent solutions.
79-
- **`user_data`** (`void*`) `[in]` — User-defined pointer passed through to the callback. It will be forwarded to `cuOptMIPGetSolutionCallback` when invoked.
79+
- **`user_data`** (`void *`) `[in]` — User-defined pointer passed through to the callback. It will be forwarded to `cuOptMIPGetSolutionCallback` when invoked.
8080

8181
**Returns** A status code indicating success or failure.
8282

8383
<hr />
8484

85-
#### `cuOptSetMIPSetSolutionCallback(cuOptSolverSettings settings, cuOptMIPSetSolutionCallback callback, void* user_data) -> cuopt_int_t`
85+
#### `cuOptSetMIPSetSolutionCallback(cuOptSolverSettings settings, cuOptMIPSetSolutionCallback callback, void * user_data) -> cuopt_int_t`
8686

8787
Register a callback to inject MIP solutions.
8888

@@ -94,7 +94,7 @@ Registering a set-solution callback disables presolve. The callback arguments re
9494

9595
- **`settings`** (`cuOptSolverSettings`) `[in]` — The solver settings object.
9696
- **`callback`** (`cuOptMIPSetSolutionCallback`) `[in]` — Callback function to inject solutions.
97-
- **`user_data`** (`void*`) `[in]` — User-defined pointer passed through to the callback. It will be forwarded to `cuOptMIPSetSolutionCallback` when invoked.
97+
- **`user_data`** (`void *`) `[in]` — User-defined pointer passed through to the callback. It will be forwarded to `cuOptMIPSetSolutionCallback` when invoked.
9898

9999
**Returns** A status code indicating success or failure.
100100

0 commit comments

Comments
 (0)