Skip to content

Commit f8f1659

Browse files
committed
[#82348] Add API docs
1 parent 251ecaf commit f8f1659

File tree

8 files changed

+53
-1
lines changed

8 files changed

+53
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
https://github.com/antmicro/antmicro-sphinx-utils/archive/main.zip
22
pydantic==2.4.2 #2.5.0 causes AttributeError during sphinx execution
3+
sphinxcontrib-httpdomain
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
Protoplaster Server API Reference
3+
---------------------------------
4+
5+
Error Handling
6+
~~~~~~~~~~~~~~
7+
8+
Should an error occur during the handling of an API request, either because of incorrect request data or other endpoint-specific scenarios, the server will return an error structure containing a user-friendly description of the error.
9+
An example error response is shown below:
10+
11+
.. sourcecode:: json
12+
13+
{
14+
"error": "test start failed"
15+
}
16+
17+
18+
Configs API
19+
~~~~~~~~~~~
20+
21+
.. autoflask:: protoplaster.protoplaster:create_docs_app()
22+
:modules: protoplaster.api.v1.configs
23+
:undoc-static:
24+
:order: path
25+
26+
Test Runs API
27+
~~~~~~~~~~~~~
28+
29+
.. autoflask:: protoplaster.protoplaster:create_docs_app()
30+
:modules: protoplaster.api.v1.test_runs
31+
:undoc-static:
32+
:order: path

.github/docs-template/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
# If you need to add extensions just add to those lists
3939
extensions = default_extensions
40+
extensions.append('sphinxcontrib.autohttp.flask')
41+
extensions.append('sphinxcontrib.autohttp.flaskqref')
4042
myst_enable_extensions = default_myst_enable_extensions
4143
myst_fence_as_directive = default_myst_fence_as_directive
4244

.github/docs-template/source/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:maxdepth: 2
55
66
introduction
7+
api
78
readme
89
protoplaster
910
report

.github/docs-template/source/introduction.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
This documentation serves as an example of how individual projects documentation can look like.
44

5-
The second chapter contains information from the README file.
5+
The second chapter contains reference of remote API when running Protoplaster in server mode.
6+
7+
The third chapter contains information from the README file.
68

79
The last chapter is generated from the sample ``test.yml`` file which can be found in the README.
810
Its purpose is to demonstrate the documentation generated to describe test procedures used in a project.

.github/scripts/latex.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ python3 -m venv ./venv
88
. ./venv/bin/activate
99

1010
pip3 install -r requirements.txt
11+
pip3 install ../
1112

1213
cd build/latex
1314
LATEXMKOPTS='-interaction=nonstopmode' make

.github/scripts/sphinx.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ python3 -m venv ./venv
88
. ./venv/bin/activate
99

1010
pip3 install -r requirements.txt
11+
pip3 install ../
1112

1213
make html latex
1314

protoplaster/protoplaster.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@
4242
app = Flask(__name__)
4343

4444

45+
def create_docs_app() -> Flask:
46+
"""Create an app that can be used for building the docs
47+
48+
This only registers the available API routes, this cannot be used to run
49+
the server! Used for dynamically building the API reference chapter in
50+
the documentation.
51+
"""
52+
app = Flask(__name__)
53+
app.register_blueprint(protoplaster.api.v1.create_routes())
54+
return app
55+
56+
4557
init()
4658

4759

0 commit comments

Comments
 (0)