Commit Graph

21 Commits

Author SHA1 Message Date
William S Fulton 5fcb0ace4f Doxygen misc constructs: cover @{ group marker and /// @file variant
Adds two test fixtures to lock down the corner cases of the #3403 fix:

- SlashFileHeaderTestClass exercises the same @file bleed scenario but
  with single-line /// comments, which take a different scanner branch
  to //!.  Without the fix the file header would bleed into the class
  description in this style too.

- GroupedMembers exercises @name/@{ member grouping.  The discard rule
  must NOT fire here: @{ does not terminate the structural block (no
  blank line), so each member's own doc comment must still attach.  A
  regression here would either drop @{ or drop the per-member doc.

Java and Python runmes are kept in step.

Assisted-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 23:27:03 +01:00
Joachim Wuttke (o) d50e235551 Fix -doxygen: @file block bleeds into first class docstring
When a header uses consecutive `//!` (or `///`) single-line comments for a
file-level block starting with `@file`, SWIG's comment accumulation loop was
concatenating the file-header content into the following class or function
docstring.

Two bugs conspired:
- Only the `@file` line itself was recognised as structural and skipped;
  subsequent lines (`@brief`, `@authors`, ...) are not in `structuralTags[]`
  and so were accumulated into `yylval.str`.
- Blank lines between comment groups do not break the accumulation loop
  (all `SWIG_TOKEN_ENDLINE` tokens are consumed silently), so the next
  declaration's own doc comment was appended to the same string.

Fix: introduce an `in_structural_block` flag. When the first comment in a
group contains a structural command (`@file`, `@page`, ...), set the flag but
continue accumulating content normally. Count newlines in the inner do-while;
when `in_structural_block` is set and two or more consecutive newlines are seen
(a blank line), discard all accumulated content and break, so the following
declaration's doc comment is processed fresh.

Not breaking the loop on a natural exit (no blank line) is deliberate: it
correctly handles the `@name`/`@{` member-grouping pattern, where `@{`
immediately follows `@name` without a blank line and must still be attached to
the next member.

The block-comment style (`/*! @file ... */`) was already handled correctly
because the entire block is one scanner token and `isStructuralDoxygen()`
would see `@file` in it.

Fixes #3403
2026-05-15 23:24:44 +01:00
William S Fulton 8a24c19d26 Fix syntax error for misplaced Doxygen comment after struct/class member.
Fix syntax error using Doxygen member groups syntax, "///*}", when used after
final struct/class member.

Issue #1636
2022-12-06 21:31:38 +00:00
William S Fulton dc04564023 Improved handling of Doxygen comments in parameter lists
Fix garbled Doxygen post comments in parameter lists.
Fix syntax error parsing a trailing Doxygen comment in parameter lists.

Closes #2023
2022-12-05 19:47:59 +00:00
William S Fulton f7b4127310 Fix syntax error parsing of Doxygen comments after last enum item
It is unconventional to have a doxygen comment after an enum item. It is
attached to the previous, that is, the enum item to match Doxygen behaviour.

Closes #1609
2022-12-03 10:09:37 +00:00
William S Fulton 24f75aa481 Fix parsing of unconventional Doxygen post comments for enum items.
Closes #1715
2022-12-03 09:49:42 +00:00
Vadim Zeitlin f57b096c92 Fix generated Python code for Doxygen comments with triple quotes
In addition to the changes in the previous commit, also avoid syntax
errors in the generated Python docstrings by splitting them into several
parts if there are 3 quotes in a row in the input, as it's impossible to
have them inside triple-quoted strings, generally speaking (i.e. if
there are occurrences of both """ and ''' inside the string).
2020-03-04 00:57:31 +01:00
Vadim Zeitlin b81cd1bdab Fix generated Python code for Doxygen comments ending with quote
Single-line Doxygen comments ending with a double quote resulted in
syntactically-invalid Python docstrings in the output, so use triple
single quotes as delimiters in this case to avoid it.
2020-03-04 00:56:27 +01:00
Vadim Zeitlin 66a7826192 Rewrite Doxygen unit tests for Java using Java 9 API
In particular, do not use com.sun.javadoc deprecated since Java 9 and
finally removed in Java 13, to allow the tests to run under modern JRE.

They don't run under Java 8 and earlier any more, but this shouldn't be
a huge problem nowadays and as SWIG output is independent from the Java
version used, it's enough to test it with modern Java versions.

Note that the tests themselves were changed only in the most minimal
way, to adapt them to the new way of running javadoc (which is now also
integrated into CommentParser itself instead of being duplicated in
every test).
2019-12-18 02:45:06 +01:00
Vadim Zeitlin 01a2cd27e7 Don't crash if type is not available in Python Doxygen code
Fix crash if "@return" Doxygen tag was used on a node without any return
type (such as a class, for example). Ignoring it might not be the best
thing to do, but it's definitely better than crashing and it's not
really clear what else could be done anyhow.

Closes #1516.
2019-04-20 13:52:05 +02:00
luz.paz ed28e7cbe2 Misc. typo and whitespace fixes
Found via `codespell -q 3 -L "uint,bae,objext,cmo,goin,struc,ois,upto"`
whitespaces were unintentionally fixed due to my editors settings.

Rebased patch #1327
2018-09-19 20:29:14 +01:00
Vadim Zeitlin 14ba3b8dd4 Preserve relative indentation when parsing Doxygen comments.
This is important to preserve the structure of the lists which appear
correctly in Python output without any additional effort if the indentation is
lost.

It is also makes the behaviour consistent for

	/**
	 *
	 *
	 */

comments and those without the asterisks in the middle lines, as now the
indentation is preserved in both cases while it was only preserved when the
asterisks were present previously.
2014-08-22 17:45:22 +02:00
Marko Klopcic b5dea7456b improved handling of word commands if puntuation is following the word, preserved spaces at start of comment line 2013-02-21 09:05:11 +01:00
Marko Klopcic 2a8b20785e fixed bug in handling of HTML tags, test added 2013-02-19 07:25:13 +01:00
Marko Klopcic 0d66568ba3 minor refactoring of CommentParser.java 2013-01-29 08:39:35 +01:00
Marko Klopcic 2896938879 only whitespace cnhanges and code comment update 2013-01-29 08:13:03 +01:00
Marko Klopcic a2a345be39 improved handling of @see tags - SWIG no longer crashes if right brace is missing 2013-01-28 22:25:40 +01:00
Marko Klopcic 8de06366cf fixed handling of quoted text adn standalone backslash and @ 2013-01-23 23:15:36 +01:00
Marko Klopcic 8d61aae0fb fixed handling of /******/ comments, added tests for backslash handling, which fail
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13733 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-09-06 20:56:19 +00:00
Marko Klopcic e62580acb8 fixed doxy documentation (also shortened lines), added test for discovered bug reltaed to nested enums
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13728 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-28 20:59:32 +00:00
Marko Klopcic af74b4f96a renamed test case
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13726 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-27 20:25:00 +00:00