Skip to content

Commit de3f9ac

Browse files
authored
feat: Add model docs script (#43)
* feat: add script to generate model sphinx docs. * fix: changed models to sections.
1 parent 5e2c320 commit de3f9ac

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

scripts/generate_model_autodoc.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# Copyright AGNTCY Contributors (https://github.com/agntcy)
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Note: This script generates the sphinx rst docs for the
6+
# package models.
7+
8+
echo "API Models
9+
===============
10+
"
11+
12+
for model in agntcy_acp/acp_v0/models/[a-z]*.py ; do
13+
awk -f - "${model}" <<'EOF'
14+
/^class/ && /BaseModel/ {
15+
match($2, "[^(]+");
16+
MODEL = substr($2,RSTART,RLENGTH-RSTART+1);
17+
printf("\`\`%s\`\`\n", MODEL);
18+
print("***************************************");
19+
printf(".. autopydantic_model:: agntcy_acp.models.%s\n", MODEL);
20+
print(" :members:");
21+
print(" :undoc-members:");
22+
print(" :show-inheritance:\n");
23+
}
24+
/^class/ && /Enum/ {
25+
match($2, "[^(]+");
26+
MODEL = substr($2,RSTART,RLENGTH-RSTART+1);
27+
printf("\`\`%s\`\`\n", MODEL);
28+
print("***************************************");
29+
printf(".. autoclass:: agntcy_acp.models.%s\n", MODEL);
30+
print(" :members:");
31+
print(" :undoc-members:");
32+
print(" :show-inheritance:\n");
33+
}
34+
EOF
35+
done

0 commit comments

Comments
 (0)