EasyDocPy 1.2.1__tar.gz → 1.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {easydocpy-1.2.1 → easydocpy-1.4.1}/EasyDocPy.egg-info/PKG-INFO +46 -24
- easydocpy-1.4.1/EasyDocPy.egg-info/SOURCES.txt +26 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/PKG-INFO +46 -24
- {easydocpy-1.2.1 → easydocpy-1.4.1}/README.md +45 -23
- easydocpy-1.4.1/easydoc/__init__.py +6 -0
- easydocpy-1.4.1/easydoc/__main__.py +59 -0
- easydocpy-1.4.1/easydoc/classes/__init__.py +20 -0
- easydocpy-1.4.1/easydoc/classes/exceptions.py +11 -0
- easydocpy-1.4.1/easydoc/classes/parsed_objects.py +136 -0
- easydocpy-1.4.1/easydoc/classes/tree_objects.py +197 -0
- easydocpy-1.4.1/easydoc/config/custom_comment_lines.json +9 -0
- easydocpy-1.4.1/easydoc/core/FileParser.py +312 -0
- easydocpy-1.4.1/easydoc/core/InteractiveManager.py +114 -0
- easydocpy-1.4.1/easydoc/core/TreatmentManager.py +127 -0
- easydocpy-1.4.1/easydoc/core/__init__.py +25 -0
- easydocpy-1.4.1/easydoc/core/utils/__init__.py +23 -0
- easydocpy-1.4.1/easydoc/core/utils/const.py +33 -0
- easydocpy-1.4.1/easydoc/core/utils/function_utils.py +13 -0
- easydocpy-1.4.1/easydoc/generators/HTMLGenerator.py +14 -0
- easydocpy-1.4.1/easydoc/generators/MarkdownGenerator.py +317 -0
- easydocpy-1.4.1/easydoc/generators/__init__.py +11 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/pyproject.toml +1 -1
- easydocpy-1.2.1/EasyDocPy.egg-info/SOURCES.txt +0 -15
- easydocpy-1.2.1/easydoc/__init__.py +0 -11
- easydocpy-1.2.1/easydoc/__main__.py +0 -29
- easydocpy-1.2.1/easydoc/analyser.py +0 -359
- easydocpy-1.2.1/easydoc/config/custom_comment_lines.json +0 -10
- easydocpy-1.2.1/easydoc/generator.py +0 -155
- easydocpy-1.2.1/easydoc/objects.py +0 -44
- {easydocpy-1.2.1 → easydocpy-1.4.1}/EasyDocPy.egg-info/dependency_links.txt +0 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/EasyDocPy.egg-info/entry_points.txt +0 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/EasyDocPy.egg-info/top_level.txt +0 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/LICENSE +0 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/easydoc/templates/template.md +0 -0
- {easydocpy-1.2.1 → easydocpy-1.4.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: EasyDocPy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: python documentation generator
|
|
5
5
|
Author: epsilonkn
|
|
6
6
|
License-Expression: MIT
|
|
@@ -157,11 +157,11 @@ Explains a constant in the code. for now, all the constants are written at the b
|
|
|
157
157
|
DEFAULT = "VOID"
|
|
158
158
|
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
## Generate the documentation :
|
|
161
161
|
|
|
162
|
-
###
|
|
162
|
+
### For a file :
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
To generate a documentation in command line :
|
|
165
165
|
|
|
166
166
|
easydoc file "/your/path/to/file.py"
|
|
167
167
|
|
|
@@ -169,35 +169,57 @@ Note 1 : your terminal must be in the directory where you want to see the docume
|
|
|
169
169
|
|
|
170
170
|
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
171
171
|
|
|
172
|
-
### In a python program :
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
### For a directory :
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
Unfortunately, in the actual state of the module, the control over the module is still very little, this will be improved in the next updates.
|
|
175
|
+
To generate a documentation in command line :
|
|
178
176
|
|
|
179
|
-
|
|
177
|
+
easydoc dir "/your/path/to/dir"
|
|
180
178
|
|
|
181
|
-
|
|
179
|
+
Note 1 : your terminal must be in the directory where you want to see the documentation generated.
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
parse_list = parser.get_parse()
|
|
185
|
-
file_header = parser.get_intro()
|
|
181
|
+
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
186
182
|
|
|
187
|
-
MarkdownGenerator(parse_list, file_header, doc_file_name)
|
|
188
183
|
|
|
184
|
+
### Advanced generation :
|
|
189
185
|
|
|
186
|
+
You can also choose to generate the documentation interactively :
|
|
190
187
|
|
|
191
|
-
|
|
188
|
+
easydoc interactive
|
|
189
|
+
|
|
190
|
+
This way the package will ask you to enter the parameters, here they are :
|
|
191
|
+
|
|
192
|
+
__mandatory :__
|
|
193
|
+
|
|
194
|
+
- _type_ : type of document to treat : file | dir
|
|
195
|
+
- _path_ : the path to what you want to treat (file or dir)
|
|
192
196
|
|
|
193
|
-
|
|
194
|
-
|-|-|
|
|
195
|
-
|V 1.2.0 | adding custom comment line to add info to the documentation|
|
|
196
|
-
|V 1.3.0| better control over the process when done in a program |
|
|
197
|
-
|V 1.4.0| adding doc generation for an entire directory |
|
|
198
|
-
|V 1.5.0| adding user configuration |
|
|
199
|
-
|......||
|
|
197
|
+
__optional :__
|
|
200
198
|
|
|
201
|
-
|
|
199
|
+
- _run_ : start the generation
|
|
200
|
+
- _help_ : shows all the options and their usage
|
|
201
|
+
- _exit_ : close the generation
|
|
202
|
+
- _format_ | f : The format of the documentation | HTML implemented in (V1.5)
|
|
203
|
+
- _language | lang_ : The language in which to doc is written | NOT IMPLEMENTED YET (V1.6 planned)
|
|
204
|
+
- _recursive | rec_ : (dir only) : Enable/disable recursive file search in subdirs
|
|
205
|
+
- _recursive_depth | rec_d_ : (dir only) Depth of recursive search, 0 equals to disable the recursive search
|
|
206
|
+
- _onefile | of_ : (dir only) If enable, will generate the whole directory doc in a single file instead a doc file per source file
|
|
207
|
+
|
|
208
|
+
### Others arguements :
|
|
209
|
+
|
|
210
|
+
__-v | --version :__ Shows the version of the package and stop the program.
|
|
211
|
+
|
|
212
|
+
__--debug :__ Start the debug mode for generation, meaning package will print at each step what it's doing.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
## Next updates :
|
|
202
216
|
|
|
203
|
-
|
|
217
|
+
|Version | Improvement| Status|
|
|
218
|
+
|-|-|-|
|
|
219
|
+
|V 1.2.0 | Adding custom comment line to add info to the documentation| Done |
|
|
220
|
+
|V 1.3.0| Better control over the process when done in a program | suppressed from the planning |
|
|
221
|
+
|V 1.4.0| V 4 : treatment of dirs \ V 1.4.1 : implementing main file usage in the process \ V 1.4.2 - implementing file meta data in onefile dir doc| In test...|
|
|
222
|
+
|V 1.5.0| Generating the doc as a html file | |
|
|
223
|
+
|V 1.6.0| Translation in differents languages | |
|
|
224
|
+
|V 1.?.0| Adding user configuration | |
|
|
225
|
+
|......|||
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
EasyDocPy.egg-info/PKG-INFO
|
|
5
|
+
EasyDocPy.egg-info/SOURCES.txt
|
|
6
|
+
EasyDocPy.egg-info/dependency_links.txt
|
|
7
|
+
EasyDocPy.egg-info/entry_points.txt
|
|
8
|
+
EasyDocPy.egg-info/top_level.txt
|
|
9
|
+
easydoc/__init__.py
|
|
10
|
+
easydoc/__main__.py
|
|
11
|
+
easydoc/classes/__init__.py
|
|
12
|
+
easydoc/classes/exceptions.py
|
|
13
|
+
easydoc/classes/parsed_objects.py
|
|
14
|
+
easydoc/classes/tree_objects.py
|
|
15
|
+
easydoc/config/custom_comment_lines.json
|
|
16
|
+
easydoc/core/FileParser.py
|
|
17
|
+
easydoc/core/InteractiveManager.py
|
|
18
|
+
easydoc/core/TreatmentManager.py
|
|
19
|
+
easydoc/core/__init__.py
|
|
20
|
+
easydoc/core/utils/__init__.py
|
|
21
|
+
easydoc/core/utils/const.py
|
|
22
|
+
easydoc/core/utils/function_utils.py
|
|
23
|
+
easydoc/generators/HTMLGenerator.py
|
|
24
|
+
easydoc/generators/MarkdownGenerator.py
|
|
25
|
+
easydoc/generators/__init__.py
|
|
26
|
+
easydoc/templates/template.md
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: EasyDocPy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: python documentation generator
|
|
5
5
|
Author: epsilonkn
|
|
6
6
|
License-Expression: MIT
|
|
@@ -157,11 +157,11 @@ Explains a constant in the code. for now, all the constants are written at the b
|
|
|
157
157
|
DEFAULT = "VOID"
|
|
158
158
|
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
## Generate the documentation :
|
|
161
161
|
|
|
162
|
-
###
|
|
162
|
+
### For a file :
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
To generate a documentation in command line :
|
|
165
165
|
|
|
166
166
|
easydoc file "/your/path/to/file.py"
|
|
167
167
|
|
|
@@ -169,35 +169,57 @@ Note 1 : your terminal must be in the directory where you want to see the docume
|
|
|
169
169
|
|
|
170
170
|
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
171
171
|
|
|
172
|
-
### In a python program :
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
### For a directory :
|
|
175
174
|
|
|
176
|
-
|
|
177
|
-
Unfortunately, in the actual state of the module, the control over the module is still very little, this will be improved in the next updates.
|
|
175
|
+
To generate a documentation in command line :
|
|
178
176
|
|
|
179
|
-
|
|
177
|
+
easydoc dir "/your/path/to/dir"
|
|
180
178
|
|
|
181
|
-
|
|
179
|
+
Note 1 : your terminal must be in the directory where you want to see the documentation generated.
|
|
182
180
|
|
|
183
|
-
|
|
184
|
-
parse_list = parser.get_parse()
|
|
185
|
-
file_header = parser.get_intro()
|
|
181
|
+
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
186
182
|
|
|
187
|
-
MarkdownGenerator(parse_list, file_header, doc_file_name)
|
|
188
183
|
|
|
184
|
+
### Advanced generation :
|
|
189
185
|
|
|
186
|
+
You can also choose to generate the documentation interactively :
|
|
190
187
|
|
|
191
|
-
|
|
188
|
+
easydoc interactive
|
|
189
|
+
|
|
190
|
+
This way the package will ask you to enter the parameters, here they are :
|
|
191
|
+
|
|
192
|
+
__mandatory :__
|
|
193
|
+
|
|
194
|
+
- _type_ : type of document to treat : file | dir
|
|
195
|
+
- _path_ : the path to what you want to treat (file or dir)
|
|
192
196
|
|
|
193
|
-
|
|
194
|
-
|-|-|
|
|
195
|
-
|V 1.2.0 | adding custom comment line to add info to the documentation|
|
|
196
|
-
|V 1.3.0| better control over the process when done in a program |
|
|
197
|
-
|V 1.4.0| adding doc generation for an entire directory |
|
|
198
|
-
|V 1.5.0| adding user configuration |
|
|
199
|
-
|......||
|
|
197
|
+
__optional :__
|
|
200
198
|
|
|
201
|
-
|
|
199
|
+
- _run_ : start the generation
|
|
200
|
+
- _help_ : shows all the options and their usage
|
|
201
|
+
- _exit_ : close the generation
|
|
202
|
+
- _format_ | f : The format of the documentation | HTML implemented in (V1.5)
|
|
203
|
+
- _language | lang_ : The language in which to doc is written | NOT IMPLEMENTED YET (V1.6 planned)
|
|
204
|
+
- _recursive | rec_ : (dir only) : Enable/disable recursive file search in subdirs
|
|
205
|
+
- _recursive_depth | rec_d_ : (dir only) Depth of recursive search, 0 equals to disable the recursive search
|
|
206
|
+
- _onefile | of_ : (dir only) If enable, will generate the whole directory doc in a single file instead a doc file per source file
|
|
207
|
+
|
|
208
|
+
### Others arguements :
|
|
209
|
+
|
|
210
|
+
__-v | --version :__ Shows the version of the package and stop the program.
|
|
211
|
+
|
|
212
|
+
__--debug :__ Start the debug mode for generation, meaning package will print at each step what it's doing.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
## Next updates :
|
|
202
216
|
|
|
203
|
-
|
|
217
|
+
|Version | Improvement| Status|
|
|
218
|
+
|-|-|-|
|
|
219
|
+
|V 1.2.0 | Adding custom comment line to add info to the documentation| Done |
|
|
220
|
+
|V 1.3.0| Better control over the process when done in a program | suppressed from the planning |
|
|
221
|
+
|V 1.4.0| V 4 : treatment of dirs \ V 1.4.1 : implementing main file usage in the process \ V 1.4.2 - implementing file meta data in onefile dir doc| In test...|
|
|
222
|
+
|V 1.5.0| Generating the doc as a html file | |
|
|
223
|
+
|V 1.6.0| Translation in differents languages | |
|
|
224
|
+
|V 1.?.0| Adding user configuration | |
|
|
225
|
+
|......|||
|
|
@@ -144,11 +144,11 @@ Explains a constant in the code. for now, all the constants are written at the b
|
|
|
144
144
|
DEFAULT = "VOID"
|
|
145
145
|
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
## Generate the documentation :
|
|
148
148
|
|
|
149
|
-
###
|
|
149
|
+
### For a file :
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
To generate a documentation in command line :
|
|
152
152
|
|
|
153
153
|
easydoc file "/your/path/to/file.py"
|
|
154
154
|
|
|
@@ -156,35 +156,57 @@ Note 1 : your terminal must be in the directory where you want to see the docume
|
|
|
156
156
|
|
|
157
157
|
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
158
158
|
|
|
159
|
-
### In a python program :
|
|
160
159
|
|
|
161
|
-
|
|
160
|
+
### For a directory :
|
|
162
161
|
|
|
163
|
-
|
|
164
|
-
Unfortunately, in the actual state of the module, the control over the module is still very little, this will be improved in the next updates.
|
|
162
|
+
To generate a documentation in command line :
|
|
165
163
|
|
|
166
|
-
|
|
164
|
+
easydoc dir "/your/path/to/dir"
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
Note 1 : your terminal must be in the directory where you want to see the documentation generated.
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
parse_list = parser.get_parse()
|
|
172
|
-
file_header = parser.get_intro()
|
|
168
|
+
Note 2 : you can pass the path without double quotes, however it is better to keep them if your path got spaces in it.
|
|
173
169
|
|
|
174
|
-
MarkdownGenerator(parse_list, file_header, doc_file_name)
|
|
175
170
|
|
|
171
|
+
### Advanced generation :
|
|
176
172
|
|
|
173
|
+
You can also choose to generate the documentation interactively :
|
|
177
174
|
|
|
178
|
-
|
|
175
|
+
easydoc interactive
|
|
176
|
+
|
|
177
|
+
This way the package will ask you to enter the parameters, here they are :
|
|
178
|
+
|
|
179
|
+
__mandatory :__
|
|
180
|
+
|
|
181
|
+
- _type_ : type of document to treat : file | dir
|
|
182
|
+
- _path_ : the path to what you want to treat (file or dir)
|
|
179
183
|
|
|
180
|
-
|
|
181
|
-
|-|-|
|
|
182
|
-
|V 1.2.0 | adding custom comment line to add info to the documentation|
|
|
183
|
-
|V 1.3.0| better control over the process when done in a program |
|
|
184
|
-
|V 1.4.0| adding doc generation for an entire directory |
|
|
185
|
-
|V 1.5.0| adding user configuration |
|
|
186
|
-
|......||
|
|
184
|
+
__optional :__
|
|
187
185
|
|
|
188
|
-
|
|
186
|
+
- _run_ : start the generation
|
|
187
|
+
- _help_ : shows all the options and their usage
|
|
188
|
+
- _exit_ : close the generation
|
|
189
|
+
- _format_ | f : The format of the documentation | HTML implemented in (V1.5)
|
|
190
|
+
- _language | lang_ : The language in which to doc is written | NOT IMPLEMENTED YET (V1.6 planned)
|
|
191
|
+
- _recursive | rec_ : (dir only) : Enable/disable recursive file search in subdirs
|
|
192
|
+
- _recursive_depth | rec_d_ : (dir only) Depth of recursive search, 0 equals to disable the recursive search
|
|
193
|
+
- _onefile | of_ : (dir only) If enable, will generate the whole directory doc in a single file instead a doc file per source file
|
|
194
|
+
|
|
195
|
+
### Others arguements :
|
|
196
|
+
|
|
197
|
+
__-v | --version :__ Shows the version of the package and stop the program.
|
|
198
|
+
|
|
199
|
+
__--debug :__ Start the debug mode for generation, meaning package will print at each step what it's doing.
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
## Next updates :
|
|
189
203
|
|
|
190
|
-
|
|
204
|
+
|Version | Improvement| Status|
|
|
205
|
+
|-|-|-|
|
|
206
|
+
|V 1.2.0 | Adding custom comment line to add info to the documentation| Done |
|
|
207
|
+
|V 1.3.0| Better control over the process when done in a program | suppressed from the planning |
|
|
208
|
+
|V 1.4.0| V 4 : treatment of dirs \ V 1.4.1 : implementing main file usage in the process \ V 1.4.2 - implementing file meta data in onefile dir doc| In test...|
|
|
209
|
+
|V 1.5.0| Generating the doc as a html file | |
|
|
210
|
+
|V 1.6.0| Translation in differents languages | |
|
|
211
|
+
|V 1.?.0| Adding user configuration | |
|
|
212
|
+
|......|||
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#/actual_version : 1.2.8
|
|
2
|
+
#/TODO Add language option support and improved CLI validation
|
|
3
|
+
#/file_intro
|
|
4
|
+
"""
|
|
5
|
+
This script is the CLI entry point for EasyDoc. It parses CLI options,
|
|
6
|
+
validates the requested path, and starts file or directory documentation generation.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from argparse import ArgumentParser
|
|
10
|
+
from importlib.metadata import version
|
|
11
|
+
|
|
12
|
+
from easydoc.core import (
|
|
13
|
+
TreatmentManager,
|
|
14
|
+
InteractiveManager,
|
|
15
|
+
is_valid_path,
|
|
16
|
+
TYPES,
|
|
17
|
+
FORMATS,
|
|
18
|
+
LANGUAGES
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
parser = ArgumentParser()
|
|
22
|
+
parser.add_argument("-v", "--version",
|
|
23
|
+
action="store_true",
|
|
24
|
+
help="show the version of EasyDocPy and exit")
|
|
25
|
+
parser.add_argument("type",
|
|
26
|
+
nargs="?",
|
|
27
|
+
choices= TYPES + ["interactive"],
|
|
28
|
+
help="the type of document to treat, either a single file or a whole directory, interactive mode allows to set the arguments interactively")
|
|
29
|
+
parser.add_argument("path",
|
|
30
|
+
nargs="?",
|
|
31
|
+
help="the path to the file or directory to document")
|
|
32
|
+
parser.add_argument("-f", "--format",
|
|
33
|
+
choices=FORMATS,
|
|
34
|
+
help="the format of the documentation to generate")
|
|
35
|
+
parser.add_argument("-l", "--language",
|
|
36
|
+
choices=LANGUAGES,
|
|
37
|
+
help="the language of the documentation to generate")
|
|
38
|
+
parser.add_argument("--debug",
|
|
39
|
+
default=False,
|
|
40
|
+
action="store_true",
|
|
41
|
+
help="enable debug mode")
|
|
42
|
+
args = parser.parse_args()
|
|
43
|
+
|
|
44
|
+
if args.version:
|
|
45
|
+
print("EasyDocPy", version("EasyDocPy"))
|
|
46
|
+
exit(0)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
match args.type :
|
|
51
|
+
case "file" | "dir":
|
|
52
|
+
if not is_valid_path(args.path):
|
|
53
|
+
raise ValueError(f"Invalid path: The path {args.path} doesn't point to a python file")
|
|
54
|
+
TreatmentManager(path = args.path, type = args.type, format = args.format, debug = args.debug)
|
|
55
|
+
case "interactive":
|
|
56
|
+
modif_args = InteractiveManager.run()
|
|
57
|
+
TreatmentManager(**modif_args, debug=args.debug)
|
|
58
|
+
case _ :
|
|
59
|
+
raise ValueError(f"Invalid value for type : {args.type}. The type of document to treat must be [{', '.join(TYPES)}] or 'interactive'")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#/actual_version : 1.0.0
|
|
2
|
+
#/file_intro
|
|
3
|
+
"""
|
|
4
|
+
This package initializer exposes the parsed object and tree classes
|
|
5
|
+
needed by the EasyDoc core modules.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .parsed_objects import *
|
|
9
|
+
from .exceptions import *
|
|
10
|
+
from .tree_objects import Node, Leaf
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"Parsed_file",
|
|
14
|
+
"Parsed_class",
|
|
15
|
+
"Parsed_function",
|
|
16
|
+
"Custom_comment",
|
|
17
|
+
"NotDeveloppedError",
|
|
18
|
+
"Node",
|
|
19
|
+
"Leaf"
|
|
20
|
+
]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#/actual_version : 1.2.0
|
|
2
|
+
#/TODO Update parsed object for decorators and nested classes
|
|
3
|
+
#/TODO Take in count the return type of the functions
|
|
4
|
+
#/file_intro
|
|
5
|
+
"""
|
|
6
|
+
This module declares the parsed object containers that represent file structure,
|
|
7
|
+
function and class metadata, and extracted custom comments.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
from typing import Union
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Parsed_object:
|
|
15
|
+
|
|
16
|
+
def __init__(self, name : str, level : int = 0):
|
|
17
|
+
"""Initialize a parsed object.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
name (str): The file name or file path.
|
|
21
|
+
content_list (list[Parsed_class, Parsed_function]): Parsed classes and functions.
|
|
22
|
+
file_data (list[Custom_comment]): Custom comments extracted from the file.
|
|
23
|
+
"""
|
|
24
|
+
self.name = name
|
|
25
|
+
self.content : list["Parsed_object"] = []
|
|
26
|
+
self.comments : list["Custom_comment"] = []
|
|
27
|
+
self.level = level
|
|
28
|
+
self.docstring : str = ""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def add_content(self, content : Union["Parsed_object"]):
|
|
32
|
+
self.content.append(content)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def add_comment(self, data : "Custom_comment"):
|
|
36
|
+
self.comments.append(data)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class Parsed_file(Parsed_object):
|
|
41
|
+
"""Represents a parsed Python file and its content."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, name : str):
|
|
44
|
+
"""Initialize a parsed file container.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
name (str): The file name or file path.
|
|
48
|
+
content_list (list[Parsed_class, Parsed_function]): Parsed classes and functions.
|
|
49
|
+
file_data (list[Custom_comment]): Custom comments extracted from the file.
|
|
50
|
+
"""
|
|
51
|
+
super().__init__(name, 0)
|
|
52
|
+
self.name = name
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Parsed_function(Parsed_object):
|
|
56
|
+
"""Represents a parsed function """
|
|
57
|
+
|
|
58
|
+
def __init__(self, declaration : str, type_ : str, level : int = 1):
|
|
59
|
+
"""Initialize a parsed function.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
declaration (str): The declaration line or block containing the def.
|
|
63
|
+
docstring (str): The docstring content associated with the declaration.
|
|
64
|
+
"""
|
|
65
|
+
super().__init__("", level)
|
|
66
|
+
self.declaration : str = ""
|
|
67
|
+
self.set_declaration(declaration)
|
|
68
|
+
self.funct_type = type_
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def set_declaration(self, declaration):
|
|
72
|
+
"""Extract the function name from the declaration.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
declaration (str): The function declaration string.
|
|
76
|
+
"""
|
|
77
|
+
self.declaration = declaration
|
|
78
|
+
self.name = re.search(r"^\s*def\s+([a-zA-Z_]\w*)", declaration).group(1)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def __str__(self):
|
|
82
|
+
"""Return the parsed element name."""
|
|
83
|
+
return self.name
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Custom_comment:
|
|
88
|
+
"""Represents a custom comment block extracted from source files."""
|
|
89
|
+
|
|
90
|
+
def __init__(self, type_ : str, ref : str , title : str, is_list : bool, content : str):
|
|
91
|
+
"""Initialize a custom comment block.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
type_ (str): The type of custom comment.
|
|
95
|
+
ref (str): The reference token used to replace custom comment placeholders.
|
|
96
|
+
title (str): The title of the custom comment.
|
|
97
|
+
is_list (bool): Whether the comment should be treated as a list.
|
|
98
|
+
content (str): The comment content.
|
|
99
|
+
"""
|
|
100
|
+
self.type_ : str = type_
|
|
101
|
+
self.title : str = title
|
|
102
|
+
self.ref : str = ref
|
|
103
|
+
self.is_list : bool = is_list
|
|
104
|
+
self.content : str = content
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Parsed_class(Parsed_object):
|
|
109
|
+
"""Represents a parsed class and its methods."""
|
|
110
|
+
|
|
111
|
+
def __init__(self, declaration, level : int = 1):
|
|
112
|
+
"""Initialize a parsed class.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
declaration (str): The class declaration string.
|
|
116
|
+
docstring (str): The class docstring content.
|
|
117
|
+
"""
|
|
118
|
+
super().__init__("", level)
|
|
119
|
+
self.declaration : str = ""
|
|
120
|
+
self.set_declaration(declaration)
|
|
121
|
+
self.level = level
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def set_declaration(self, declaration):
|
|
125
|
+
"""Extract the class name from the declaration.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
declaration (str): The class declaration string.
|
|
129
|
+
"""
|
|
130
|
+
self.declaration = declaration
|
|
131
|
+
self.name = re.search(r"^\s*class\s+([a-zA-Z_]\w*)", declaration).group(1)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def __str__(self):
|
|
135
|
+
"""Return the class name."""
|
|
136
|
+
return self.name
|