summaryrefslogtreecommitdiffstats
path: root/contrib/tools/swig/Source/Doxygen/doxytranslator.cxx
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-08-28 14:27:58 +0300
committerrobot-piglet <[email protected]>2025-08-28 14:57:06 +0300
commit81d828c32c8d5477cb2f0ce5da06a1a8d9392ca3 (patch)
tree3081d566f0d5158d76e9093261344f6406fd09f7 /contrib/tools/swig/Source/Doxygen/doxytranslator.cxx
parent77ea11423f959e51795cc3ef36a48d808b4ffb98 (diff)
Intermediate changes
commit_hash:d5b1af16dbe9030537a04c27eb410c88c2f496cd
Diffstat (limited to 'contrib/tools/swig/Source/Doxygen/doxytranslator.cxx')
-rw-r--r--contrib/tools/swig/Source/Doxygen/doxytranslator.cxx69
1 files changed, 69 insertions, 0 deletions
diff --git a/contrib/tools/swig/Source/Doxygen/doxytranslator.cxx b/contrib/tools/swig/Source/Doxygen/doxytranslator.cxx
new file mode 100644
index 00000000000..a638717eca1
--- /dev/null
+++ b/contrib/tools/swig/Source/Doxygen/doxytranslator.cxx
@@ -0,0 +1,69 @@
+/* -----------------------------------------------------------------------------
+ * This file is part of SWIG, which is licensed as a whole under version 3
+ * (or any later version) of the GNU General Public License. Some additional
+ * terms also apply to certain portions of SWIG. The full details of the SWIG
+ * license and copyrights can be found in the LICENSE and COPYRIGHT files
+ * included with the SWIG source code as distributed by the SWIG developers
+ * and at https://www.swig.org/legal.html.
+ *
+ * doxytranslator.cxx
+ *
+ * Module to return documentation for nodes formatted for various documentation
+ * systems.
+ * ----------------------------------------------------------------------------- */
+
+#include "doxytranslator.h"
+
+DoxygenTranslator::DoxygenTranslator(int flags) : m_flags(flags), parser((flags &debug_parser) != 0) {
+}
+
+
+DoxygenTranslator::~DoxygenTranslator() {
+}
+
+
+bool DoxygenTranslator::hasDocumentation(Node *node) {
+ return getDoxygenComment(node) != NULL;
+}
+
+
+String *DoxygenTranslator::getDoxygenComment(Node *node) {
+ return Getattr(node, "doxygen");
+}
+
+/**
+ * Indent all lines in the comment by given indentation string
+ */
+void DoxygenTranslator::extraIndentation(String *comment, const_String_or_char_ptr indentationString) {
+ if (indentationString || Len(indentationString) > 0) {
+ int len = Len(comment);
+ bool trailing_newline = len > 0 && *(Char(comment) + len - 1) == '\n';
+ Insert(comment, 0, indentationString);
+ String *replace = NewStringf("\n%s", indentationString);
+ Replaceall(comment, "\n", replace);
+ if (trailing_newline) {
+ len = Len(comment);
+ Delslice(comment, len - 2, len); // Remove added trailing spaces on last line
+ }
+ Delete(replace);
+ }
+}
+
+String *DoxygenTranslator::getDocumentation(Node *node, const_String_or_char_ptr indentationString) {
+
+ if (!hasDocumentation(node)) {
+ return NewString("");
+ }
+
+ String *documentation = makeDocumentation(node);
+ extraIndentation(documentation, indentationString);
+ return documentation;
+}
+
+
+void DoxygenTranslator::printTree(const DoxygenEntityList &entityList) {
+
+ for (DoxygenEntityListCIt p = entityList.begin(); p != entityList.end(); p++) {
+ p->printEntity(0);
+ }
+}