Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
0b7be5d0
Commit
0b7be5d0
authored
1 year ago
by
Iziram
Browse files
Options
Downloads
Patches
Plain Diff
gen api doc : catégories
parent
c12bc778
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/api/assiduites.py
+4
-0
4 additions, 0 deletions
app/api/assiduites.py
tools/create_api_map.py
+33
-6
33 additions, 6 deletions
tools/create_api_map.py
with
37 additions
and
6 deletions
app/api/assiduites.py
+
4
−
0
View file @
0b7be5d0
...
...
@@ -341,6 +341,10 @@ def evaluation_assiduites(evaluation_id):
]
}
``
`
CATEGORY
--------
evaluations
"""
# Récupération de l'évaluation
try
:
...
...
This diff is collapsed.
Click to expand it.
tools/create_api_map.py
+
33
−
6
View file @
0b7be5d0
...
...
@@ -4,6 +4,7 @@ Script permettant de générer une carte SVG de l'API de ScoDoc
Écrit par Matthias HARTMANN
"""
import
sys
import
xml.etree.ElementTree
as
ET
import
re
...
...
@@ -508,6 +509,14 @@ def analyze_api_routes(app, endpoint_start: str) -> tuple:
if
child
.
query
and
not
href
.
endswith
(
"
-query
"
):
href
+=
"
-query
"
# category
category
:
str
=
func
.
__module__
.
replace
(
"
app.api.
"
,
""
)
mod_doc
:
str
=
sys
.
modules
[
func
.
__module__
].
__doc__
or
""
mod_doc_dict
:
dict
=
_parse_doc_string
(
mod_doc
)
if
mod_doc_dict
.
get
(
"
CATEGORY
"
):
category
=
mod_doc_dict
[
"
CATEGORY
"
][
0
].
strip
()
permissions
:
str
try
:
permissions
:
str
=
"
,
"
.
join
(
...
...
@@ -525,6 +534,7 @@ def analyze_api_routes(app, endpoint_start: str) -> tuple:
"
permission
"
:
permissions
,
"
description
"
:
doc_dict
.
get
(
""
,
""
),
"
params
"
:
doc_dict
.
get
(
"
PARAMS
"
,
""
),
"
category
"
:
doc_dict
.
get
(
"
CATEGORY
"
,
[
False
])[
0
]
or
category
,
}
# On met à jour le token courant pour le prochain segment
...
...
@@ -544,8 +554,6 @@ def gen_api_map(app, endpoint_start="api."):
puis génère un fichier SVG à partir de cet arbre
"""
print
(
"
DEBUG
"
,
app
.
view_functions
[
"
apiweb.user_info
"
].
scodoc_permission
)
api_map
,
doctable_lines
=
analyze_api_routes
(
app
,
endpoint_start
)
# On génère le SVG à partir de l'arbre de Token
...
...
@@ -903,10 +911,29 @@ def doc_route(doctable: dict) -> str:
def
gen_api_doc
(
app
,
endpoint_start
=
"
api.
"
):
"
commande gen-api-doc
"
_
,
doctable_lines
=
analyze_api_routes
(
app
,
endpoint_start
)
mddoc
=
"
\n
"
.
join
(
doc_route
(
doctable
)
for
doctable
in
sorted
(
doctable_lines
.
values
(),
key
=
lambda
x
:
x
[
"
nom
"
])
)
mddoc
:
str
=
""
categories
:
dict
=
{}
for
value
in
doctable_lines
.
values
():
category
=
value
[
"
category
"
]
if
category
not
in
categories
:
categories
[
category
]
=
[]
categories
[
category
].
append
(
value
)
# sort categories by name
categories
:
dict
=
dict
(
sorted
(
categories
.
items
(),
key
=
lambda
x
:
x
[
0
]))
category
:
str
routes
:
list
[
dict
]
for
category
,
routes
in
categories
.
items
():
# sort routes by name
routes
.
sort
(
key
=
lambda
x
:
x
[
"
nom
"
])
mddoc
+=
f
"
### API
{
category
.
capitalize
()
}
\n\n
"
for
route
in
routes
:
mddoc
+=
doc_route
(
route
)
mddoc
+=
"
\n\n
"
fname
=
"
/tmp/apidoc.md
"
with
open
(
fname
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment