Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 23389d2

Browse files
authored
ci: configure read the docs (#1266)
Closes #1264. ### Summary of Changes Build documentation site and upload it to Read the Docs. --------- Co-authored-by: lars-reimann <[email protected]>
1 parent d02b1b4 commit 23389d2

14 files changed

+214
-79
lines changed

.mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
EXTENDS: https://raw.githubusercontent.com/lars-reimann/.github/main/.mega-linter.yml
44

55
# Config
6-
FILTER_REGEX_EXCLUDE: (\.github/workflows/)
6+
FILTER_REGEX_EXCLUDE: (\.github/workflows/|mkdocs.yml)
77

88
# Commands
99
PRE_COMMANDS:

README.md renamed to docs/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="img/logo_with_text.svg" alt="logo" height="75">
1+
# API-Editor
22

33
[![Main](https://github.com/lars-reimann/api-editor/actions/workflows/main.yml/badge.svg)](https://github.com/lars-reimann/api-editor/actions/workflows/main.yml)
44
[![DOI](https://zenodo.org/badge/365253624.svg)](https://zenodo.org/badge/latestdoi/365253624)
@@ -17,7 +17,7 @@ The automation described above relies on structured information about the existi
1717
```
1818
4. Open [localhost:4280](http://localhost:4280) in your browser.
1919
5. In the window that opens, enter your username in the bottom right field.
20-
6. Download the contents of the [`data`](data) folder of this project. Alternatively, compute the required data for another Python API using the [package-parser][package-parser].
20+
6. Download the contents of the [`data`][data] folder of this project. Alternatively, compute the required data for another Python API using the [package-parser][package-parser].
2121
7. Open `File > Import > API Data` and upload the API data that you stored locally.
2222
8. Open `File > Import > Usages` and upload the usage data that you stored locally.
2323
9. Open `File > Import > Annotations` and upload the annotation data that you stored locally (from the repository or your own prior usages of the tool).
@@ -48,6 +48,7 @@ Now you are ready to explore the API and review existing annotations.
4848
```
4949
3. Open [localhost:5173](http://localhost:5173) in your browser.
5050

51-
[package-parser]: ./package-parser
51+
[data]: https://github.com/Safe-DS/API-Editor/tree/main/data
52+
[package-parser]: package-parser
5253
[safe-ds]: https://github.com/lars-reimann/safe-data-science
5354
[adapter-pattern]: https://en.wikipedia.org/wiki/Adapter_pattern
Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
# Manual for api-editor
2+
23
## General
4+
35
The purpose of the _api-editor_ is to manually annotate classes, functions, and parameters from a given API
46
to generate an improved API. The _package-parser_, in contrast, marks annotations automatically.
57
These annotations can be imported, edited and deleted in the _api-editor_.
68

79
## Import
8-
Before you can start adding own annotations, you need to import the [generated API, usages and annotations files](../package-parser/README.md) from _package-parser_.
910

10-
<img src="img/import.jpg" alt="Import API Data">
11+
Before you can start adding own annotations, you need to import the [generated API, usages and annotations files](package-parser/README.md) from _package-parser_.
12+
13+
![Import API Data](img/import.jpg)
1114

1215
Now you can select packages, classes, functions, or parameters from the tree view on the right side and see the further information (documentation, annotation, etc.) about the selected element on the left side.
1316

1417
## Annotations
18+
1519
An improved API is created through annotations.
1620
_Package-parser_ automatically generates some types of annotations by the documentation and the number of calls.
1721
These are `Boundary`, `Constant`, `Enum`, `Optional`, `Remove`, and `Required`.
1822
The other annotations cannot be generated, but are set manually with _api-editor_.
1923

20-
<img src="img/annotation.jpg" alt="Creation of a new annotation" style="max-width: 800px;">
24+
![Creation of a new annotation](img/annotation.jpg)
2125

2226
To add new annotations, select the corresponding class, function, or parameter in the tree view
2327
and choose the desired annotation from the drop-down menu on the left.
@@ -26,96 +30,108 @@ To edit an annotation, click on the annotation in the selected component of the
2630
and to delete it, click on the red trash button on the right side of the annotation panel.
2731

2832
### List of annotations and their meaning
29-
* ### Boundary
30-
The annotation is used for numerical parameters, that should be in a specific range.
31-
The interval can be open or closed, and can have no upper or lower limit.
32-
_Continuous_ or _Discrete_ refers to the set of real numbers or integers.
3333

34-
<img src="img/boundary.jpg" alt="Edit a boundary annotation" style="max-width: 450px;">
34+
- ### Boundary
35+
The annotation is used for numerical parameters, that should be in a specific range.
36+
The interval can be open or closed, and can have no upper or lower limit.
37+
_Continuous_ or _Discrete_ refers to the set of real numbers or integers.
38+
39+
![Edit a boundary annotation](img/boundary.jpg)
40+
41+
- ### CalledAfter
42+
43+
When a function may only be called after another function, it should be marked with a CalledAfter annotation.
44+
The two functions must be in the same class.
45+
46+
- ### Constant
47+
Parameters that are assigned only one value are marked with this annotation.
48+
The function `f(x, y)` where x has a constant annotation will be a local variable with the result that `f(y)` has one parameter less.
49+
Permitted types are primitive data types or None.
3550

36-
* ### CalledAfter
37-
When a function may only be called after another function, it should be marked with a CalledAfter annotation.
38-
The two functions must be in the same class.
51+
![Add a constant annotation](img/constant.jpg)
3952

40-
* ### Constant
41-
Parameters that are assigned only one value are marked with this annotation.
42-
The function ``f(x, y)`` where x has a constant annotation will be a local variable with the result that ``f(y)`` has one parameter less.
43-
Permitted types are primitive data types or None.
53+
- ### Enum
54+
The annotation is for string parameters that require specific words as input, and they should be converted to an enum.
55+
Its elements contain a string value which is the value of the parameter and an instance name for the name of the element.
4456

45-
<img src="img/constant.jpg" alt="Add a constant annotation" style="max-width: 450px;">
57+
![Edit an enum annotation](img/enum.jpg)
4658

59+
- ### Group
60+
A group annotation is applicable on a function, but user-defined parameters are grouped into a single parameter in the enhanced API.
61+
For that purpose, a new class with the selected parameters will be created.
62+
The list of parameters of the method will contain the not selected parameters and one from the type of the new created class.
4763

48-
* ### Enum
49-
The annotation is for string parameters that require specific words as input, and they should be converted to an enum.
50-
Its elements contain a string value which is the value of the parameter and an instance name for the name of the element.
64+
![Add a group annotation](img/group.jpg)
5165

52-
<img src="img/enum.jpg" alt="Edit an enum annotation" style="max-width: 450px;">
66+
- ### Move
5367

54-
* ### Group
55-
A group annotation is applicable on a function, but user-defined parameters are grouped into a single parameter in the enhanced API.
56-
For that purpose, a new class with the selected parameters will be created.
57-
The list of parameters of the method will contain the not selected parameters and one from the type of the new created class.
68+
Classes with this annotation will be moved to a custom module.
5869

59-
<img src="img/group.jpg" alt="Add a group annotation" style="max-width: 500px;">
70+
- ### Optional
6071

61-
* ### Move
62-
Classes with this annotation will be moved to a custom module.
72+
A new default value for the parameter should be added. e.g, The function `f(x=1)` would be converted to `f(x)`.
6373

64-
* ### Optional
65-
A new default value for the parameter should be added. e.g, The function ``f(x=1)`` would be converted to ``f(x)``.
74+
- ### Pure
6675

67-
* ### Pure
68-
This annotation applies to functions that have no side effects and whose return value is the same if the parameters passed in the calls are the same.
69-
An invocation of such a function can be deleted if the return value isn't assigned.
70-
The second attribute allows the function to be cached.
76+
This annotation applies to functions that have no side effects and whose return value is the same if the parameters passed in the calls are the same.
77+
An invocation of such a function can be deleted if the return value isn't assigned.
78+
The second attribute allows the function to be cached.
7179

72-
* ### Remove
73-
A class or a function that is marked with this annotation should be removed.
80+
- ### Remove
7481

75-
* ### Rename
76-
This annotation renames a class, function, or parameter.
82+
A class or a function that is marked with this annotation should be removed.
7783

78-
* ### Required
79-
An optional Parameter should be required. It is the opposite action of [Optional](#optional).
84+
- ### Rename
85+
86+
This annotation renames a class, function, or parameter.
87+
88+
- ### Required
89+
An optional Parameter should be required. It is the opposite action of [Optional](#optional).
8090

8191
## Features
92+
8293
There are features for a better overview of the API and its usages.
8394

8495
### Filter
96+
8597
For a better listing, there is a text box filter in the top right corner that can filter the elements of the API.
8698
The available commands for filtering are displayed when you press the help button on its right side.
87-
If an ``!`` is before a command, it negates that filter.
99+
If an `!` is before a command, it negates that filter.
88100
Multiple commands are interpreted as an and operation.
89101
The elements that meet the filter are printed in bold in the tree view.
90102

91-
<img src="img/filter.jpg" alt="Filter for 'is:public name:x is:parameter' is set and the help panel for filtering is open" style="max-height: 650px;">
103+
![Filter for 'is:public name:x is:parameter' is set and the help panel for filtering is open](img/filter.jpg)
92104

93105
### Heat Map
106+
94107
To get a heat map for the number of annotations or calls, go to Settings → Heat Map Mode and click on the desired view.
95108
There are two options for the number of times the API is used.
96109
_Usages_ shows the total number of calls and _usefullness_ subtract out the internal calls.
97110
The third option is for the number of annotations that a class, function, or parameter has.
98111

99-
<img src="img/heat_map.jpg" alt="In the tree view, the heat map is activated and in the menu bar, the drop-down menu of Settings is open and ''Usefulness'' is selected." style="max-height: 650px;">
112+
![In the tree view, the heat map is activated and in the menu bar, the drop-down menu of Settings is open and 'Usefulness' is selected.](img/heat_map.jpg)
100113

101114
In the tree view of all components of the API,
102115
the number of uses or the number of annotations of an individual component is color-coded in a box to the left of its name.
103116
The warmer the color of the box, the more often the component is used or the more annotations it has.
104117
The absolute number can be found in the box.
105118

106119
### Navigation bar
107-
<img src="img/navigation.jpg" alt="Navigation bar with the buttons: previous, next, expand / collapse all, expand / collapse selected">
120+
121+
![Navigation bar with the buttons: previous, next, expand / collapse all, expand / collapse selected](img/navigation.jpg)
108122

109123
At the bottom right is a panel with six buttons for better handling of the tree view:
110124
_Previous_ and _Next_ select the previous or next item in the tree view that meet the [filter](#filter).
111125
The other four buttons expand or collapse the entire tree view or only the selected element and all elements contained in it recursively.
112126

113127
### Delete all annotations
128+
114129
On the menu bar is a button to delete all annotations. Use this button wisely, or export the annotations (File → Export → Annotations) before proceeding.
115130

116131
## Generate API
132+
117133
The button _Generate adapters_ creates the improved API.
118134
If there are any conflicts with annotations, they will be displayed and a new API won't be generated.
119135
e.g, a module cannot have the annotations remove and move. One of them should be removed.
120136
After generation, you can select the folder in which the file is to be stored.
121-
It is a zip file with two folders. They are _adapter_ which contains the new API and [_stub_](https://github.com/lars-reimann/safe-data-science/blob/main/docs/DSL/stub-language/README.md).
137+
It is a zip file with two folders. They are _adapter_ which contains the new API and stubs.

docs/javascript/mathjax.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
window.MathJax = {
2+
tex: {
3+
inlineMath: [['\\(', '\\)']],
4+
displayMath: [['\\[', '\\]']],
5+
processEscapes: true,
6+
processEnvironments: true,
7+
},
8+
options: {
9+
ignoreHtmlClass: '.*|',
10+
processHtmlClass: 'arithmatex',
11+
},
12+
};
13+
14+
document$.subscribe(() => {
15+
MathJax.typesetPromise();
16+
});
File renamed without changes.

docs/package-parser.md renamed to docs/package-parser/architecture.md

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ end
1818
1919
```
2020

21-
Can be found [here](../package-parser/package_parser/processing/annotations/_generate_annotations.py).
22-
2321
### `generate_annotations()`
2422

2523
Serves as a central function that takes care of inputs and outputs and bundles all underlying functions. The exact
@@ -123,8 +121,6 @@ AnnotationStore "0..1" o-- "*" BaseAnnotation
123121
124122
```
125123

126-
Can be found [here](../package-parser/package_parser/model/annotations/_annotations.py).
127-
128124
The AnnotationStore class is used for the collection of the individual annotations. An instance of this class is passed
129125
to the individual `get_[type]_annotation()` functions. These then place their results in the list assigned to them.
130126

@@ -149,8 +145,6 @@ ParameterType <.. ParameterInfo
149145
}
150146
```
151147

152-
Can be found [here](../package-parser/package_parser/model/annotations/_annotations.py).
153-
154148
The ParameterInfo class is used to encapsulate the collected information for a given parameter which is generated in
155149
the `get_parameter_info()` function.
156150

@@ -182,10 +176,7 @@ classDiagram
182176
}
183177
```
184178

185-
Can be found [here](../package-parser/package_parser/model/usages/_usages.py).
186-
187-
This class is a slimmed down version of the [UsageStore](../package-parser/package_parser/model/usages/_usages.py)
188-
class.
179+
This class is a slimmed down version of the UsageStore class.
189180

190181
For the automatic generation of annotations, it is in most cases sufficient to know how often a certain element (class,
191182
function, parameter, value) is used. In the original class, there are more details stored for each usage, which leads to
@@ -223,21 +214,21 @@ The path specifies where the results are to be stored.
223214

224215
This function needs to be executed before the data can be analyzed and performs the following three tasks:
225216

226-
- `remove_internal_usages()`
217+
- `remove_internal_usages()`
227218

228-
Since we are only concerned with the use of outward-facing package elements, all elements that are used exclusively
229-
internally are excluded from consideration.
219+
Since we are only concerned with the use of outward-facing package elements, all elements that are used exclusively
220+
internally are excluded from consideration.
230221

231-
- `add_unused_api_elements()`
222+
- `add_unused_api_elements()`
232223

233-
Some API elements are not used at all and, therefore, do not appear in the listing of all used elements. However, it
234-
is necessary that they do for the following process of the program.
224+
Some API elements are not used at all and, therefore, do not appear in the listing of all used elements. However, it
225+
is necessary that they do for the following process of the program.
235226

236-
- `add_implicit_usages_of_default_value()`
227+
- `add_implicit_usages_of_default_value()`
237228

238-
If no value is supplied for an optional parameter when a function is called, the default value of the parameter is
239-
used implicitly. This implicit use of a value does not appear in the usage data. However, it is necessary that they do
240-
so for later analysis.
229+
If no value is supplied for an optional parameter when a function is called, the default value of the parameter is
230+
used implicitly. This implicit use of a value does not appear in the usage data. However, it is necessary that they do
231+
so for later analysis.
241232

242233
All functions of the form `get_[type]_annotation()` are passed in a list to the `generate_annotation_dict()` function.
243234
This function then calls them one after the other.
@@ -261,25 +252,18 @@ call_annotation_getter --> dump_annotation_store
261252

262253
### `AnnotationStore`
263254

264-
Can be found [here](../package-parser/tests/model/test_annotations.py).
265-
266255
For the `AnnotationStore` and all associated classes there are automatic tests that ensure that the `to_json()` methods
267256
work properly. For this purpose, a test configuration of the individual classes is created, and their output is then
268257
compared against the expected value.
269258

270259
### `UsageCountStore`
271260

272-
Can be found [here](../package-parser/tests/model/test_usages.py).
273-
274261
For this class, there are automatic checks for the input and output methods, that compare the actual result against the
275262
expected value. There are also various tests for every setter and getter in which the state of the object is checked
276263
after.
277264

278265
### `generate_annotations()`
279266

280-
The tests can be found [here](../package-parser/tests/commands/generate_annotations/test_generate_annotations.py) and
281-
the test data [here](../package-parser/tests/data).
282-
283267
For this function, all called functions are tested automatically. For this purpose, there is test data for each
284268
individual getter, for which the output is then compared against the expected value. We decided to split the test data
285269
and test the called functions as standalone, because the implementation of tests for new features would otherwise lead

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mkdocs==1.4.2
2+
mkdocs-glightbox==0.3.1
3+
mkdocs-material==9.1.0

img/logo.afdesign

-22.8 MB
Binary file not shown.

img/logo_with_text.afdesign

-10.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)