docstring-generator-ext 2.0.6__tar.gz → 2.0.7__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.
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/PKG-INFO +1 -1
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/docstring_generator_ext.egg-info/PKG-INFO +1 -1
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/pyproject.toml +1 -1
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/docstringFormat.cpp +18 -7
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/docstringFormat.hpp +3 -3
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/parser.cpp +7 -2
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/parser.hpp +3 -2
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/MANIFEST.in +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/README.md +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/docstring_generator_ext.egg-info/SOURCES.txt +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/docstring_generator_ext.egg-info/dependency_links.txt +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/docstring_generator_ext.egg-info/requires.txt +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/docstring_generator_ext.egg-info/top_level.txt +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/setup.cfg +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/setup.py +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/FunctionFormat.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/FunctionFormat.hpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/GoogleDocstring.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/GoogleDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/IDocstringFormat.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/IDocstringFormat.hpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/NumpyDocstring.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/NumpyDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/ReStructuredDocstring.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/ReStructuredDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/docComparator.cpp +0 -0
- {docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/docComparator.hpp +0 -0
|
@@ -38,7 +38,7 @@ std::optional<std::string> read_file(const std::string &file_path) {
|
|
|
38
38
|
return file_content;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const DocstringFormatStyle &formatStyle) {
|
|
41
|
+
std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const DocstringFormatStyle &formatStyle, const bool ignore_magic) {
|
|
42
42
|
std::vector<FunctionInfo> infos{};
|
|
43
43
|
py::module ast_module = py::module_::import("ast");
|
|
44
44
|
const py::object generator_result = ast_module.attr("walk")(ast_module.attr("parse")(text));
|
|
@@ -49,7 +49,11 @@ std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const Doc
|
|
|
49
49
|
obj,
|
|
50
50
|
ast_module.attr("AsyncFunctionDef")
|
|
51
51
|
)) {
|
|
52
|
-
|
|
52
|
+
const auto res = analyze_function(obj, ast_module, ignore_magic);
|
|
53
|
+
if (!res.has_value()) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
FunctionInfo function_info = *res;
|
|
53
57
|
function_info.update_descriptions(formatStyle);
|
|
54
58
|
infos.emplace_back(function_info);
|
|
55
59
|
}
|
|
@@ -58,13 +62,13 @@ std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const Doc
|
|
|
58
62
|
return infos;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
void parse_file(const std::string &file_path, const DocstringFormatStyle &formatStyle, const bool &allow_overwrite) {
|
|
65
|
+
void parse_file(const std::string &file_path, const DocstringFormatStyle &formatStyle, const bool &allow_overwrite, const bool &ignore_magic) {
|
|
62
66
|
const auto result = read_file(file_path);
|
|
63
67
|
if (!result.has_value()) {
|
|
64
68
|
throw py::value_error(file_path + " is not a valid path.");
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
std::vector<FunctionInfo> infos = createFunctionInfos(*result, formatStyle);
|
|
71
|
+
std::vector<FunctionInfo> infos = createFunctionInfos(*result, formatStyle, ignore_magic);
|
|
68
72
|
|
|
69
73
|
std::ranges::sort(
|
|
70
74
|
infos,
|
|
@@ -92,7 +96,7 @@ void parse_file(const std::string &file_path, const DocstringFormatStyle &format
|
|
|
92
96
|
#endif
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
std::map<std::string, int> check_docstrings(std::string &file_path) {
|
|
99
|
+
std::map<std::string, int> check_docstrings(std::string &file_path, const bool &ignore_magic) {
|
|
96
100
|
int function_checked = 0;
|
|
97
101
|
int complete_docstring = 0;
|
|
98
102
|
int partial_docstring = 0;
|
|
@@ -109,7 +113,12 @@ std::map<std::string, int> check_docstrings(std::string &file_path) {
|
|
|
109
113
|
)) {
|
|
110
114
|
++function_checked;
|
|
111
115
|
|
|
112
|
-
const
|
|
116
|
+
const auto res = analyze_function(obj, ast_module, ignore_magic);
|
|
117
|
+
if (!res.has_value()) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const FunctionInfo function_info = *res;
|
|
113
122
|
|
|
114
123
|
switch (compare_docstrings(function_info.docstring, function_info)) {
|
|
115
124
|
case IS_EMPTY:
|
|
@@ -231,13 +240,15 @@ PYBIND11_MODULE(docstring_generator_ext, m) {
|
|
|
231
240
|
py::arg("file_path"),
|
|
232
241
|
py::arg("formatStyle"),
|
|
233
242
|
py::arg("allow_overwrite") = false,
|
|
243
|
+
py::arg("ignore_magic") = false,
|
|
234
244
|
"The file_path where automatically docstrings should be added.",
|
|
235
245
|
"In which style should the Docstring be written."
|
|
236
246
|
);
|
|
237
247
|
m.def(
|
|
238
248
|
"check_docstring",
|
|
239
249
|
&check_docstrings,
|
|
240
|
-
py::arg("file_path")
|
|
250
|
+
py::arg("file_path"),
|
|
251
|
+
py::arg("ignore_magic") = false
|
|
241
252
|
);
|
|
242
253
|
|
|
243
254
|
py::enum_<DocstringFormatStyle>(m, "DocstringFormatStyle")
|
|
@@ -16,9 +16,9 @@ enum WriteResult {
|
|
|
16
16
|
|
|
17
17
|
void get_docstring_arg_descr(FunctionInfo &functionInfo) noexcept;
|
|
18
18
|
|
|
19
|
-
[[nodiscard]] std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const DocstringFormatStyle &formatStyle);
|
|
19
|
+
[[nodiscard]] std::vector<FunctionInfo> createFunctionInfos(const std::string &text, const DocstringFormatStyle &formatStyle, bool ignore_magic = false);
|
|
20
20
|
|
|
21
|
-
void parse_file(const std::string &file_path, const DocstringFormatStyle &formatStyle, const bool &allow_overwrite = false);
|
|
21
|
+
void parse_file(const std::string &file_path, const DocstringFormatStyle &formatStyle, const bool &allow_overwrite = false, const bool &ignore_magic = false);
|
|
22
22
|
|
|
23
23
|
/*
|
|
24
24
|
* {
|
|
@@ -28,6 +28,6 @@ void parse_file(const std::string &file_path, const DocstringFormatStyle &format
|
|
|
28
28
|
* 'no_docstrings': 0,
|
|
29
29
|
* }
|
|
30
30
|
*/
|
|
31
|
-
std::map<std::string, int> check_docstrings(std::string &file_path);
|
|
31
|
+
std::map<std::string, int> check_docstrings(std::string &file_path, const bool &ignore_magic = false);
|
|
32
32
|
|
|
33
33
|
#endif //DOCSTRING_GENERATOR_EXT_DOCSTRINGFORMAT_HPP
|
|
@@ -454,9 +454,10 @@ void get_exception(
|
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
FunctionInfo analyze_function(
|
|
457
|
+
std::optional<FunctionInfo> analyze_function(
|
|
458
458
|
const pybind11::handle &obj,
|
|
459
|
-
py::module &ast_module
|
|
459
|
+
py::module &ast_module,
|
|
460
|
+
bool ignore_magic
|
|
460
461
|
) noexcept {
|
|
461
462
|
std::vector<FunctionException> function_exceptions{};
|
|
462
463
|
|
|
@@ -468,6 +469,10 @@ FunctionInfo analyze_function(
|
|
|
468
469
|
auto name = py::cast<std::string>(py::getattr(obj, "name"));
|
|
469
470
|
auto offset = py::cast<uint32_t>(py::getattr(obj, "col_offset"));
|
|
470
471
|
|
|
472
|
+
if (ignore_magic && name.starts_with("__")) {
|
|
473
|
+
return std::nullopt;
|
|
474
|
+
}
|
|
475
|
+
|
|
471
476
|
FunctionDocstring doc_str = get_docstring(py::reinterpret_borrow<py::object>(obj), ast_module);
|
|
472
477
|
doc_str.detect_format_style();
|
|
473
478
|
|
|
@@ -47,9 +47,10 @@ void get_exception(
|
|
|
47
47
|
const py::object &parent = py::none()
|
|
48
48
|
) noexcept;
|
|
49
49
|
|
|
50
|
-
FunctionInfo analyze_function(
|
|
50
|
+
[[nodiscard]] std::optional<FunctionInfo> analyze_function(
|
|
51
51
|
const pybind11::handle &obj,
|
|
52
|
-
py::module &ast_module
|
|
52
|
+
py::module &ast_module,
|
|
53
|
+
bool ignore_magic
|
|
53
54
|
) noexcept;
|
|
54
55
|
|
|
55
56
|
#endif //DOCSTRING_GENERATOR_EXT_PARSER_HPP
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/ReStructuredDocstring.cpp
RENAMED
|
File without changes
|
{docstring_generator_ext-2.0.6 → docstring_generator_ext-2.0.7}/src/ReStructuredDocstring.hpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|