docstring-generator-ext 2.0.5__tar.gz → 2.0.6__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.5 → docstring_generator_ext-2.0.6}/PKG-INFO +1 -1
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/docstring_generator_ext.egg-info/PKG-INFO +1 -1
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/pyproject.toml +1 -1
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/FunctionFormat.cpp +43 -6
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/FunctionFormat.hpp +6 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/GoogleDocstring.cpp +2 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/NumpyDocstring.cpp +3 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/docstringFormat.cpp +1 -2
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/MANIFEST.in +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/README.md +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/docstring_generator_ext.egg-info/SOURCES.txt +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/docstring_generator_ext.egg-info/dependency_links.txt +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/docstring_generator_ext.egg-info/requires.txt +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/docstring_generator_ext.egg-info/top_level.txt +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/setup.cfg +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/setup.py +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/GoogleDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/IDocstringFormat.cpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/IDocstringFormat.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/NumpyDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/ReStructuredDocstring.cpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/ReStructuredDocstring.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/docComparator.cpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/docComparator.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/docstringFormat.hpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/parser.cpp +0 -0
- {docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/parser.hpp +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#include "FunctionFormat.hpp"
|
|
2
2
|
|
|
3
3
|
#include <map>
|
|
4
|
+
#include <ranges>
|
|
5
|
+
|
|
4
6
|
#include "parser.hpp"
|
|
5
7
|
|
|
6
8
|
const std::map<std::string, ParameterKind> ParameterKinds = {
|
|
@@ -221,27 +223,62 @@ void FunctionDocstring::detect_format_style() noexcept {
|
|
|
221
223
|
if (!detected_format_style.has_value())
|
|
222
224
|
return -1;
|
|
223
225
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
std::vector<std::string> lines;
|
|
227
|
+
lines.reserve(256);
|
|
228
|
+
|
|
229
|
+
for (const auto&line : std::views::split(docstring, '\n') | std::views::transform([](const auto &obj){ return std::string(obj.begin(), obj.end()); })) {
|
|
230
|
+
lines.emplace_back(remove_whitespace(line));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const auto get_end_pos = [](std::vector<std::string> &_lines, StyleSections sections) {
|
|
234
|
+
std::vector<int> res;
|
|
226
235
|
std::ranges::for_each(
|
|
227
236
|
sections,
|
|
228
237
|
[&](const auto &line) {
|
|
229
|
-
|
|
238
|
+
int idx = 0;
|
|
239
|
+
for (const auto &obj: _lines) {
|
|
240
|
+
if (obj.find(line) != std::string::npos) {
|
|
241
|
+
res.emplace_back(idx);
|
|
242
|
+
}
|
|
243
|
+
idx++;
|
|
244
|
+
}
|
|
230
245
|
}
|
|
231
246
|
);
|
|
232
247
|
std::ranges::sort(res, std::less<>());
|
|
248
|
+
if (res.empty())
|
|
249
|
+
return -1;
|
|
233
250
|
return res[0];
|
|
234
251
|
};
|
|
235
252
|
|
|
253
|
+
int end_pos{};
|
|
236
254
|
switch (*detected_format_style) {
|
|
237
255
|
case DocstringFormatStyle::NUMPY:
|
|
238
|
-
|
|
256
|
+
end_pos = get_end_pos(lines, TypicalSectionStyle[0].second);
|
|
257
|
+
break;
|
|
239
258
|
case DocstringFormatStyle::GOOGLE:
|
|
240
|
-
|
|
259
|
+
end_pos = get_end_pos(lines, TypicalSectionStyle[1].second);
|
|
260
|
+
break;
|
|
241
261
|
case DocstringFormatStyle::reST:
|
|
242
|
-
|
|
262
|
+
end_pos = get_end_pos(lines, TypicalSectionStyle[2].second);
|
|
263
|
+
break;
|
|
243
264
|
}
|
|
244
265
|
|
|
266
|
+
if (end_pos == -1 || static_cast<size_t>(end_pos) > lines.size())
|
|
267
|
+
return -1;
|
|
268
|
+
|
|
269
|
+
std::string tmp = "";
|
|
270
|
+
lines.clear();
|
|
271
|
+
for (const auto&line : std::views::split(docstring, '\n') | std::views::transform([](const auto &obj){ return std::string(obj.begin(), obj.end()); })) {
|
|
272
|
+
lines.emplace_back(line);
|
|
273
|
+
}
|
|
274
|
+
for (int idx = 0; idx < end_pos; idx++) {
|
|
275
|
+
tmp += lines[idx];
|
|
276
|
+
if (idx + 1 < end_pos)
|
|
277
|
+
tmp += "\n";
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
docstring = tmp;
|
|
281
|
+
|
|
245
282
|
return -1;
|
|
246
283
|
}
|
|
247
284
|
|
|
@@ -31,6 +31,12 @@ constexpr std::array<std::pair<std::string_view, StyleSections>, 3> TypicalForma
|
|
|
31
31
|
{"rest", {":param", ":returns:", ":raises"}}
|
|
32
32
|
}};
|
|
33
33
|
|
|
34
|
+
constexpr std::array<std::pair<std::string_view, StyleSections>, 3> TypicalSectionStyle = {{
|
|
35
|
+
{"numpy", {"Parameters", "Returns", "Raises"}},
|
|
36
|
+
{"google", {"Args:", "Returns:", "Raises:"}},
|
|
37
|
+
{"rest", {":param", ":returns:", ":raises"}}
|
|
38
|
+
}};
|
|
39
|
+
|
|
34
40
|
ParameterKind from_str(const std::string &kind);
|
|
35
41
|
std::ostream &operator<<(std::ostream &out, ParameterKind const &obj) noexcept;
|
|
36
42
|
|
|
@@ -26,6 +26,8 @@ std::string GoogleDocstring::cleanArgsDescription(const std::string &arg, const
|
|
|
26
26
|
|
|
27
27
|
if (const auto startPos = res.find(arg); startPos < std::string::npos) {
|
|
28
28
|
const auto pos = startPos + arg.size() + 1;
|
|
29
|
+
if (pos > res.size())
|
|
30
|
+
return res;
|
|
29
31
|
res = res.substr(pos, res.size() - pos);
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -24,6 +24,9 @@ std::string NumpyDocstring::docstringArgs() noexcept {
|
|
|
24
24
|
docstream << "\n";
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
if (functionInfo.args.empty())
|
|
28
|
+
return "";
|
|
29
|
+
|
|
27
30
|
docstream << current_py_tab << "Parameters\n";
|
|
28
31
|
docstream << current_py_tab << "----------\n";
|
|
29
32
|
std::ranges::for_each(
|
|
@@ -170,8 +170,7 @@ std::map<std::string, int> check_docstrings(std::string &file_path) {
|
|
|
170
170
|
}
|
|
171
171
|
if (allow_overwrite && *val.docstring.detected_format_style != formatStyle) {
|
|
172
172
|
const auto pos = val.docstring.remove_old_format_style();
|
|
173
|
-
if (pos >= 0)
|
|
174
|
-
start_pos = pos;
|
|
173
|
+
if (pos >= 0) {}
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
|
|
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.5 → docstring_generator_ext-2.0.6}/src/ReStructuredDocstring.cpp
RENAMED
|
File without changes
|
{docstring_generator_ext-2.0.5 → docstring_generator_ext-2.0.6}/src/ReStructuredDocstring.hpp
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|