docstring-generator-ext 2.0.13a1__tar.gz → 2.0.14__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.
Files changed (30) hide show
  1. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/PKG-INFO +1 -1
  2. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/docstring_generator_ext.egg-info/PKG-INFO +1 -1
  3. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/pyproject.toml +1 -1
  4. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/FunctionFormat.cpp +10 -0
  5. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/GoogleDocstring.cpp +5 -3
  6. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/IDocstringFormat.cpp +3 -6
  7. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/NumpyDocstring.cpp +5 -1
  8. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/docstringFormat.cpp +1 -1
  9. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/existingDocstringExtractor.cpp +232 -9
  10. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/existingDocstringExtractor.hpp +26 -1
  11. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/parser.hpp +8 -2
  12. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/MANIFEST.in +0 -0
  13. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/README.md +0 -0
  14. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/docstring_generator_ext.egg-info/SOURCES.txt +0 -0
  15. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/docstring_generator_ext.egg-info/dependency_links.txt +0 -0
  16. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/docstring_generator_ext.egg-info/requires.txt +0 -0
  17. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/docstring_generator_ext.egg-info/top_level.txt +0 -0
  18. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/setup.cfg +0 -0
  19. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/setup.py +0 -0
  20. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/FunctionFormat.hpp +0 -0
  21. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/GoogleDocstring.hpp +0 -0
  22. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/IDocstringFormat.hpp +0 -0
  23. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/NumpyDocstring.hpp +0 -0
  24. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/ReStructuredDocstring.cpp +0 -0
  25. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/ReStructuredDocstring.hpp +0 -0
  26. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/docComparator.cpp +0 -0
  27. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/docComparator.hpp +0 -0
  28. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/docstringFormat.hpp +0 -0
  29. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/formatStyles.hpp +0 -0
  30. {docstring_generator_ext-2.0.13a1 → docstring_generator_ext-2.0.14}/src/parser.cpp +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring_generator_ext
3
- Version: 2.0.13a1
3
+ Version: 2.0.14
4
4
  Summary: Generate Docstrings with type-hint information.
5
5
  Author-email: FelixTheC <fberndt87@gmail.com>
6
6
  Classifier: Environment :: Console
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring_generator_ext
3
- Version: 2.0.13a1
3
+ Version: 2.0.14
4
4
  Summary: Generate Docstrings with type-hint information.
5
5
  Author-email: FelixTheC <fberndt87@gmail.com>
6
6
  Classifier: Environment :: Console
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "docstring_generator_ext"
3
- version = "2.0.13a1"
3
+ version = "2.0.14"
4
4
  description = "Generate Docstrings with type-hint information."
5
5
  authors = [
6
6
  { name = "FelixTheC", email = "fberndt87@gmail.com" },
@@ -131,6 +131,16 @@ void FunctionParameter::erase() {
131
131
  void FunctionInfo::update_descriptions(const DocstringFormatStyle &formatStyle) noexcept {
132
132
 
133
133
  const auto extractor = ExistingDocstringExtractor::parse_text(docstring.docstring, formatStyle);
134
+ if (!extractor.get_return_info().empty())
135
+ returns.description = extractor.get_return_info()[0].description;
136
+
137
+ if (!extractor.get_exception_info().empty()) {
138
+ for (const auto &exception: extractor.get_exception_info()) {
139
+ exceptions.emplace(exception.type, exception.description);
140
+ }
141
+ }
142
+
143
+ docstring.docstring = extractor.get_reduced_docstring();
134
144
  size_t param_idx = 0;
135
145
  // we expect that the params are in the same order, cause otherwise we had somewhere a violation agains a PEP
136
146
  for (const auto &param: extractor.get_extracted_parameters()) {
@@ -38,8 +38,10 @@ std::string GoogleDocstring::docstringSummary() noexcept {
38
38
  if (res.empty())
39
39
  return res;
40
40
  if (!functionInfo.summary_only()) {
41
- if (!res.ends_with('\n'))
41
+ if (!res.ends_with('\n')) {
42
42
  res += '\n';
43
+ res += '\n';
44
+ }
43
45
  }
44
46
  return res;
45
47
  }
@@ -85,8 +87,8 @@ std::string GoogleDocstring::docstringArgs() noexcept {
85
87
  }
86
88
 
87
89
  if (!val.default_value.empty()) {
88
- auto tmp = std::format("Defaults to {}.", val.default_value);
89
- if (val.description.empty() || val.description.find(tmp) == std::string::npos)
90
+ if (auto tmp = std::format("Defaults to {}.", val.default_value);
91
+ val.description.empty() || val.description.find(tmp) == std::string::npos)
90
92
  result += tmp;
91
93
  }
92
94
 
@@ -20,21 +20,18 @@ bool onlyQuotesAndWhitespace(const std::string &s) {
20
20
  tmp += argTxt;
21
21
  }
22
22
  if (const auto returnTxt = docstringReturn(); !returnTxt.empty()) {
23
- if (tmp.empty())
24
- tmp += '\n';
25
23
  tmp += returnTxt;
26
24
  }
27
25
  if (const auto exceptionTxt = docstringExceptions(); !exceptionTxt.empty() && exceptionTxt != "\n") {
28
- if (tmp.empty())
29
- tmp += '\n';
30
26
  tmp += exceptionTxt;
31
27
  }
32
28
 
33
29
  result += current_pytab;
34
30
  result += R"(""")";
35
31
  if (const auto summaryTxt = docstringSummary(); !summaryTxt.empty()) {
36
- if (trim(tmp) != trim(summaryTxt))
37
- result += summaryTxt;
32
+ result += summaryTxt;
33
+ if (!result.empty() && !result.ends_with('\n') && !tmp.empty())
34
+ result += '\n';
38
35
  } else {
39
36
  result += '\n';
40
37
  }
@@ -23,6 +23,7 @@ std::string NumpyDocstring::docstringSummary() noexcept {
23
23
  return res;
24
24
  if (!functionInfo.summary_only()) {
25
25
  res += '\n';
26
+ res += '\n';
26
27
  }
27
28
  return res;
28
29
  }
@@ -105,7 +106,6 @@ std::string NumpyDocstring::docstringReturn() noexcept {
105
106
  result += std::format("{}{}{}", current_py_tab, PY_TAB, functionInfo.returns.description);
106
107
  }
107
108
 
108
- result += '\n';
109
109
  result += '\n';
110
110
  return result;
111
111
  }
@@ -116,6 +116,10 @@ std::string NumpyDocstring::docstringExceptions() noexcept {
116
116
 
117
117
  std::string result;
118
118
  result.reserve(256);
119
+
120
+ if (!functionInfo.returns.type.empty())
121
+ result += '\n';
122
+
119
123
  const auto current_py_tab = get_tabs();
120
124
 
121
125
  result += std::format("{}Raises\n", current_py_tab);
@@ -207,7 +207,7 @@ std::map<std::string, int> check_docstrings(std::string &file_path, const bool &
207
207
  int start_pos = val.get_file_write_position() - 1;
208
208
  int end_pos = start_pos + 0;
209
209
 
210
- if (!val.docstring.docstring.empty()) {
210
+ if (val.docstring.end_line != 0) {
211
211
  end_pos = val.docstring.end_line;
212
212
  }
213
213
 
@@ -46,8 +46,11 @@ void DocstringParameter::extract_default_from_description() {
46
46
  }
47
47
 
48
48
  void DocstringParameter::extract_parameter_kind() {
49
- const auto kind_candidates = {ParameterKind::ARG, ParameterKind::POS_ONLY, ParameterKind::KW_ONLY, ParameterKind::VARIADIC_ARG, ParameterKind::KEYWORD_ARG};
50
- for (const auto &param_kind : kind_candidates) {
49
+ const auto kind_candidates = {
50
+ ParameterKind::ARG, ParameterKind::POS_ONLY, ParameterKind::KW_ONLY, ParameterKind::VARIADIC_ARG,
51
+ ParameterKind::KEYWORD_ARG
52
+ };
53
+ for (const auto &param_kind: kind_candidates) {
51
54
  const auto kind_str = parameter_kind::to_str(param_kind);
52
55
  if (description.find(kind_str) != std::string::npos) {
53
56
  this->kind = param_kind;
@@ -84,19 +87,39 @@ ExistingDocstringExtractor::get_extracted_parameters() const noexcept {
84
87
  return extracted_parameters;
85
88
  }
86
89
 
90
+ std::string ExistingDocstringExtractor::get_reduced_docstring() const noexcept {
91
+ return std::string(trim_right(reduced_docstring));
92
+ }
93
+
94
+ std::vector<DocstringReturnInfo> ExistingDocstringExtractor::get_return_info() const noexcept {
95
+ return docstring_return_info;
96
+ }
97
+
98
+ std::vector<DocstringExceptionInfo> ExistingDocstringExtractor::get_exception_info() const noexcept {
99
+ return docstring_exception_info;
100
+ }
101
+
87
102
  void ExistingDocstringExtractor::extract_numpy_parameters(
88
103
  std::string_view text
89
104
  ) {
105
+
106
+ reduced_docstring = text;
107
+
108
+ extract_numpy_exception_info();
109
+ extract_numpy_return_info();
110
+
90
111
  // this should be the line after parameters, cause the amount of `-` must
91
112
  // require the length of the word `Parameters` the same applies to `Raises`
92
113
  // and `Returns`
93
- const auto start_pos = text.find("Parameters");
114
+ const auto start_pos = reduced_docstring.find("Parameters");
94
115
  std::string indentation{};
95
116
  std::string level2_indentation{};
96
117
 
97
118
  if (start_pos != std::string::npos) {
98
119
  DocstringParameter existing_parameter{};
120
+ reduced_docstring = std::string(text.substr(0, start_pos));
99
121
  std::string_view param_section = text.substr(start_pos + 10);
122
+
100
123
  for (auto &&raw_line: param_section | std::views::split('\n')) {
101
124
  std::string_view line(raw_line.begin(), raw_line.end());
102
125
 
@@ -181,19 +204,65 @@ void ExistingDocstringExtractor::extract_numpy_parameters(
181
204
  }
182
205
  }
183
206
  }
207
+
208
+ const auto return_pos = reduced_docstring.find("Returns");
209
+ if (return_pos != std::string::npos) {
210
+ const auto yield_pos = reduced_docstring.find("Yields");
211
+ const auto see_pos = reduced_docstring.find("See Also");
212
+ const auto raises_pos = reduced_docstring.find("Raises");
213
+ const auto return_pos_end = std::min(std::min(yield_pos, see_pos), raises_pos);
214
+
215
+ std::string return_section;
216
+ if (return_pos_end != std::string::npos) {
217
+ return_section = reduced_docstring.substr(return_pos, return_pos_end);
218
+ } else {
219
+ return_section = reduced_docstring.substr(return_pos);
220
+ }
221
+
222
+ // for (auto &&raw_line: return_section | std::views::split('\n')) {
223
+ //
224
+ // }
225
+ reduced_docstring = reduced_docstring.substr(0, return_pos);
226
+ }
227
+
228
+ const auto yield_pos = reduced_docstring.find("Yields");
229
+ if (yield_pos != std::string::npos) {
230
+ removed_returns = true;
231
+ reduced_docstring = reduced_docstring.substr(0, yield_pos);
232
+ }
233
+
234
+ const auto see_pos = reduced_docstring.find("See Also");
235
+ if (see_pos != std::string::npos) {
236
+ removed_returns = true;
237
+ reduced_docstring = reduced_docstring.substr(0, see_pos);
238
+ }
239
+
240
+ const auto raises_pos = reduced_docstring.find("Raises");
241
+ if (raises_pos != std::string::npos) {
242
+ removed_raises = true;
243
+ reduced_docstring = reduced_docstring.substr(0, raises_pos);
244
+ }
184
245
  }
185
246
 
186
247
  void ExistingDocstringExtractor::extract_google_parameters(
187
248
  std::string_view text
188
249
  ) {
189
- const auto start_pos = text.find("Args:");
250
+
251
+ reduced_docstring = text;
252
+
253
+ extract_google_exception_info();
254
+ extract_google_return_info();
255
+
256
+ const auto start_pos = reduced_docstring.find("Args:");
190
257
  std::string indentation{};
191
258
  std::string level2_indentation{};
192
259
 
193
260
  if (start_pos != std::string::npos) {
194
261
  DocstringParameter existing_parameter{};
195
262
  // the length of the word "Args:" plus one linebreak
196
- std::string_view param_section = text.substr(start_pos + 6);
263
+ std::string param_section = reduced_docstring.substr(start_pos + 6);
264
+ reduced_docstring = std::string(text.substr(0, start_pos));
265
+
197
266
  for (auto &&raw_line: param_section | std::views::split('\n')) {
198
267
  std::string_view line(raw_line.begin(), raw_line.end());
199
268
 
@@ -283,11 +352,12 @@ void ExistingDocstringExtractor::extract_rest_parameters(
283
352
  std::string indentation{};
284
353
  std::string level2_indentation{};
285
354
 
286
- std::string_view body = text.substr(start_pos);
287
-
288
355
  if (start_pos != std::string::npos) {
289
356
  DocstringParameter existing_parameter{};
290
357
 
358
+ std::string_view body = text.substr(start_pos);
359
+ reduced_docstring = std::string(body.substr(0, start_pos));
360
+
291
361
  for (auto &&raw_line: body | std::views::split('\n')) {
292
362
  std::string_view line(raw_line.begin(), raw_line.end());
293
363
  std::string_view trimmed_line = trim(line);
@@ -319,7 +389,7 @@ void ExistingDocstringExtractor::extract_rest_parameters(
319
389
  existing_parameter.name = trim(param_name);
320
390
 
321
391
  auto trimmed_description = trim(description);
322
- const auto default_pos = trimmed_description.find("default");
392
+ const auto default_pos = trimmed_description.find("default");
323
393
 
324
394
  if (default_pos != std::string::npos) {
325
395
  existing_parameter.description = trimmed_description.substr(0, default_pos);
@@ -338,7 +408,6 @@ void ExistingDocstringExtractor::extract_rest_parameters(
338
408
  } else {
339
409
  existing_parameter.description = trim(description);
340
410
  }
341
-
342
411
  } else if (trimmed_line.starts_with(":type")) {
343
412
  std::string_view after_type = trimmed_line.substr(6);
344
413
  const auto [param_name, type_info] = split_once(after_type, ':');
@@ -375,3 +444,157 @@ void ExistingDocstringExtractor::extract_rest_parameters(
375
444
  }
376
445
  }
377
446
  }
447
+
448
+ void ExistingDocstringExtractor::extract_google_exception_info() {
449
+ const auto raises_pos = reduced_docstring.find("Raises:");
450
+
451
+ if (raises_pos != std::string::npos) {
452
+ auto raises_section = reduced_docstring.substr(raises_pos + 7);
453
+ reduced_docstring = reduced_docstring.substr(0, raises_pos);
454
+ DocstringExceptionInfo exception_info {};
455
+
456
+ for (auto &&raw_line: raises_section | std::views::split('\n')) {
457
+ std::string_view line(raw_line.begin(), raw_line.end());
458
+ if (trim(line).empty()) {
459
+ if (!exception_info.type.empty()) {
460
+ docstring_exception_info.emplace_back(exception_info);
461
+ exception_info = {};
462
+ }
463
+ continue;
464
+ }
465
+ if (line.find(':') != std::string_view::npos) {
466
+ if (!exception_info.type.empty()) {
467
+ docstring_exception_info.emplace_back(exception_info);
468
+ exception_info = {};
469
+ }
470
+ const auto [type_info, description] = split_once(line, ':');
471
+ exception_info.type = std::string(trim(type_info));
472
+ exception_info.description = std::string(trim(description));
473
+ } else {
474
+ exception_info.description += '\n';
475
+ exception_info.description += std::string(trim(line));
476
+ }
477
+ }
478
+ }
479
+ }
480
+
481
+ void ExistingDocstringExtractor::extract_google_return_info() {
482
+ auto return_pos = reduced_docstring.find("Returns:");
483
+
484
+ if (return_pos != std::string::npos) {
485
+ // we have an return section
486
+ const auto yield_pos_ = reduced_docstring.find("Yields:");
487
+ const auto see_pos_ = reduced_docstring.find("See Also:");
488
+ const auto raises_pos_ = reduced_docstring.find("Raises:");
489
+ const auto return_pos_end = std::min(std::min(yield_pos_, see_pos_), raises_pos_);
490
+
491
+ std::string return_section{};
492
+ if (return_pos_end != std::string::npos) {
493
+ return_section = reduced_docstring.substr(return_pos + 8, return_pos_end - return_pos - 8);
494
+ } else {
495
+ return_section = reduced_docstring.substr(return_pos + 8);
496
+ }
497
+
498
+ DocstringReturnInfo return_info{};
499
+ for (auto &&raw_line: return_section | std::views::split('\n')) {
500
+ std::string_view line(raw_line.begin(), raw_line.end());
501
+ if (trim(line).empty()) {
502
+ if (!return_info.type.empty()) {
503
+ docstring_return_info.emplace_back(return_info);
504
+ return_info = {};
505
+ }
506
+ continue;
507
+ }
508
+ if (line.find(':') != std::string_view::npos) {
509
+ if (!return_info.type.empty()) {
510
+ docstring_return_info.emplace_back(return_info);
511
+ return_info = {};
512
+ }
513
+ const auto [type_info, description] = split_once(line, ':');
514
+ return_info.type = std::string(trim(type_info));
515
+ return_info.description = std::string(trim(description));
516
+ } else {
517
+ return_info.description += '\n';
518
+ return_info.description += std::string(trim(line));
519
+ }
520
+ }
521
+ reduced_docstring = reduced_docstring.substr(0, return_pos);
522
+ }
523
+ }
524
+
525
+ void ExistingDocstringExtractor::extract_numpy_exception_info() {
526
+ const auto raises_pos = reduced_docstring.find("Raises");
527
+
528
+ if (raises_pos != std::string::npos) {
529
+ auto raises_section = reduced_docstring.substr(raises_pos + 7);
530
+ reduced_docstring = reduced_docstring.substr(0, raises_pos);
531
+ DocstringExceptionInfo exception_info {};
532
+
533
+ for (auto &&raw_line: raises_section | std::views::split('\n')) {
534
+ std::string_view line(raw_line.begin(), raw_line.end());
535
+ if (trim(line).empty()) {
536
+ if (!exception_info.type.empty()) {
537
+ docstring_exception_info.emplace_back(exception_info);
538
+ exception_info = {};
539
+ }
540
+ continue;
541
+ }
542
+ if (line.find(':') != std::string_view::npos) {
543
+ if (!exception_info.type.empty()) {
544
+ docstring_exception_info.emplace_back(exception_info);
545
+ exception_info = {};
546
+ }
547
+ const auto [type_info, description] = split_once(line, ':');
548
+ exception_info.type = std::string(trim(type_info));
549
+ exception_info.description = std::string(trim(description));
550
+ } else {
551
+ exception_info.description += '\n';
552
+ exception_info.description += std::string(trim(line));
553
+ }
554
+ }
555
+ }
556
+ }
557
+
558
+ void ExistingDocstringExtractor::extract_numpy_return_info() {
559
+ auto return_pos = reduced_docstring.find("Returns");
560
+
561
+ if (return_pos != std::string::npos) {
562
+ // we have an return section
563
+ const auto yield_pos_ = reduced_docstring.find("Yields");
564
+ const auto see_pos_ = reduced_docstring.find("See Also");
565
+ const auto raises_pos_ = reduced_docstring.find("Raises");
566
+ const auto return_pos_end = std::min(std::min(yield_pos_, see_pos_), raises_pos_);
567
+
568
+ std::string return_section{};
569
+ if (return_pos_end != std::string::npos) {
570
+ return_section = reduced_docstring.substr(return_pos + 8, return_pos_end - return_pos - 8);
571
+ } else {
572
+ return_section = reduced_docstring.substr(return_pos + 8);
573
+ }
574
+
575
+ DocstringReturnInfo return_info{};
576
+ for (auto &&raw_line: return_section | std::views::split('\n')) {
577
+ std::string_view line(raw_line.begin(), raw_line.end());
578
+ if (trim(line).empty()) {
579
+ if (!return_info.type.empty()) {
580
+ docstring_return_info.emplace_back(return_info);
581
+ return_info = {};
582
+ }
583
+ continue;
584
+ }
585
+ if (line.find(':') != std::string_view::npos) {
586
+ if (!return_info.type.empty()) {
587
+ docstring_return_info.emplace_back(return_info);
588
+ return_info = {};
589
+ }
590
+ const auto [type_info, description] = split_once(line, ':');
591
+ return_info.type = std::string(trim(type_info));
592
+ return_info.description = std::string(trim(description));
593
+ } else {
594
+ return_info.description += '\n';
595
+ return_info.description += std::string(trim(line));
596
+ }
597
+ }
598
+ reduced_docstring = reduced_docstring.substr(0, return_pos);
599
+ }
600
+ }
@@ -20,16 +20,41 @@ struct DocstringParameter {
20
20
  void extract_parameter_kind();
21
21
  };
22
22
 
23
+ struct DocstringReturnInfo {
24
+ std::string type {};
25
+ std::string description {};
26
+ };
27
+
28
+ struct DocstringExceptionInfo {
29
+ std::string type {};
30
+ std::string description {};
31
+ };
32
+
23
33
  class ExistingDocstringExtractor {
24
34
  public:
25
35
  static ExistingDocstringExtractor parse_text(const std::string &text, DocstringFormatStyle formatStyle);
26
- std::vector<DocstringParameter> get_extracted_parameters() const noexcept;
36
+ [[nodiscard]] std::vector<DocstringParameter> get_extracted_parameters() const noexcept;
37
+ [[ nodiscard ]] std::string get_reduced_docstring() const noexcept;
38
+ [[ nodiscard ]] std::vector<DocstringReturnInfo>get_return_info() const noexcept;
39
+ [[ nodiscard ]] std::vector<DocstringExceptionInfo> get_exception_info() const noexcept;
27
40
 
28
41
  private:
29
42
  std::vector<DocstringParameter> extracted_parameters{};
43
+ std::vector<DocstringReturnInfo> docstring_return_info{};
44
+ std::vector<DocstringExceptionInfo> docstring_exception_info{};
45
+ std::string reduced_docstring {};
46
+ bool removed_returns {false};
47
+ bool removed_raises {false};
48
+
30
49
  void extract_numpy_parameters(std::string_view text);
31
50
  void extract_google_parameters(std::string_view text);
32
51
  void extract_rest_parameters(std::string_view text);
52
+
53
+ void extract_google_exception_info();
54
+ void extract_google_return_info();
55
+
56
+ void extract_numpy_exception_info();
57
+ void extract_numpy_return_info();
33
58
  };
34
59
 
35
60
  #endif // DOCSTRING_GENERATOR_EXT_EXISTINGDOCSTRINGEXTRACTOR_HPP
@@ -53,7 +53,7 @@ void get_exception(
53
53
  bool ignore_magic
54
54
  ) noexcept;
55
55
 
56
- constexpr std::pair<std::string_view, std::string_view> split_once(std::string_view str, char delim) {
56
+ constexpr std::pair<std::string_view, std::string_view> split_once(std::string_view str, const char delim) {
57
57
  auto pos = str.find(delim);
58
58
  if (pos == std::string_view::npos) {
59
59
  return {str, {}};
@@ -61,11 +61,17 @@ constexpr std::pair<std::string_view, std::string_view> split_once(std::string_v
61
61
  return {str.substr(0, pos), str.substr(pos + 1)};
62
62
  }
63
63
 
64
- constexpr std::string_view trim(std::string_view v) {
64
+ constexpr std::string_view trim(const std::string_view v) {
65
65
  auto start = v.find_first_not_of(" \t\r\n");
66
66
  if (start == std::string_view::npos) return {};
67
67
  auto end = v.find_last_not_of(" \t\r\n");
68
68
  return v.substr(start, end - start + 1);
69
69
  }
70
70
 
71
+ constexpr std::string_view trim_right(const std::string_view v) {
72
+ auto end = v.find_last_not_of(" \t\r\n");
73
+ if (end == std::string_view::npos) return {};
74
+ return v.substr(0, end + 1);
75
+ }
76
+
71
77
  #endif //DOCSTRING_GENERATOR_EXT_PARSER_HPP