Commit graph

916 commits

Author SHA1 Message Date
John McFarland
f8ed9d71a7 Fix doxygen translation of \p command for python
Doxygen writes this using typewriter font, so wrap in `` for python
2019-09-15 10:59:03 -05:00
John McFarland
c11172587c Fix doxygen handling of \em tag for python
In doxygen, \em is used for italics, so it should be wrapped in "*".
2019-09-15 10:59:03 -05:00
John McFarland
4a5a86ba91 Special handling for python doctest code blocks
A doctest code block begins with ">>>" and is not indented.  Identify
these in doxygen comments and treat them accordingly.  Also add check
to padCodeAndVerbatimBlocks for these because Sphinx requires an empty
line before.

Add test case to doxygen_code_blocks.i.
2019-08-07 17:04:12 -05:00
John McFarland
5230afb3e1 Add new doxygen test doxygen_code_blocks
This does somewhat more detailed testing of the code block parsing,
and also exercises the language identification of python doctest
features.  For now, it is only tested by python (javadoc translation
may not correctly handle some of the characters that are used here).
2019-08-07 16:55:38 -05:00
John McFarland
fd33bdf8a5 Flag optional arguments in doxygen pydoc output
If the parameter has a default value, add the string ", optional" to
the parameter type description in the translated python comments.
Three examples with default values were already present in the test
cases, so their expected python output has been updated accordingly.
2019-08-07 16:42:39 -05:00
John McFarland
36f0e9919f Add parameter direction to doxygen pydoc output
For doxygen comments that specify parameter direction (i.e.,
\param[in], \param[out], and \param[in,out]), the direction is
appended to the type definition in the generated Python documentation.

Updated expected python output for doxygen test case.
2019-08-07 16:42:39 -05:00
John McFarland
eb11c025c7 Support doxygen \param[] commands
Recognize \param[in], \param[out], and \param[in,out].  Currently they
are all treated the same as \param, but the information is now
available for inclusion in the translated comments.  This is done
using new utility functions getBaseCommand and getEndOfWordCommand,
which will also generalize to treatment of code command options,
e.g. \code{.py}.  Preliminary treatment of the extended version of
\code is already in place in these functions.

Added examples of all three new \param commands to the
doxygen_translate_all_tags test and updated the python and java
expected output.
2019-08-07 16:42:24 -05:00
William S Fulton
a9a7b03ba6 Split testcases li_std_wstring.i and li_std_wstring_inherit.i
Not many languages have support for std_wstring.i, so disable testing
for these languages until added.
2019-07-22 19:05:21 +01:00
William S Fulton
5131096b80 li_std_wstring test rename to li_std_wstring_inherit
This testcase was only run in Ruby and Python and implements an
obscure feature where a C++ class inherits from a std::wstring.

The li_std_wstring test is left in place to be modified in next commit
for more regular wstring testing across all languages.
2019-07-18 19:49:50 +01:00
William S Fulton
c8b1eed8ce Merge branch 'annotation_quoting'
* annotation_quoting:
  Examples: Unify string quoting in the Python sources
  Test-suite: Unify string quoting in the Python sources
  Tools: Unify string quoting in the Python sources
  Generator: Unify string quoting in generated Python sources
  Generator: Remove trailing whitespaces in the Python module
2019-07-18 07:23:06 +01:00
Dmitry D. Chernov
fa5f519bf9 Test-suite: Unify string quoting in the Python sources 2019-07-14 12:58:21 +10:00
John McFarland
85a4c7ffc0 Doxygen comment parsing fix for empty lines in code/verbatim blocks
Fix how end of paragraph is identified when parsing \code and
\verbatim blocks that appear within a paragraph and contain an empty
line.  Previously this would generate a warning for unexpected end of
doxygen comments, and it could generate a segfault due to
dereferencing an invalid iterator value.

The doxygen_basic_translate.i and doxygen_basic_translate_style2.i
tests have been updated to serve as regression tests for this
behavior.  Prior to this fix, inclusion of the empty code block line
in this context produced a segfault.
2019-07-06 11:30:46 -05:00
John McFarland
daad5d664d Ensure empty line before code and math blocks in doxygen pydoc
Sphinx requires an empty line before code and math blocks, whereas
doxygen does not.  This update ensures that a blank line is included
before generated code and math blocks in the pydoc output.  This is
done by post-processing the docstring line by line to check whether
any newlines need to be added.  This way, if the original doxygen
source already includes an empty line before a block, an additional
unnecessary empty line is not added.

Updating the expected test output for doxygen_basic_translate, which
now adds the necessary empty line before the code block.  Adding
further test cases to doxygen_translate_all_tags to explicitly verify
that a newline is added in the pydoc output before both code and math
blocks that appear within a paragraph.

Additionally, empty lines previously appearing at the beginning of the
generated docstrings are now removed.  This does not alter the
behavior of the tests.
2019-06-18 17:12:08 -05:00
John McFarland
3476565665 Remove extra newline before code block in doxygen python output
Remove a newline character that was added to the translated comments
prior to the code block.  This way the structure of the pydoc output
more closely resembles that of the original doxygen comments.
Updating tests accordingly.
2019-05-27 13:06:32 -05:00
John McFarland
64b2113e66 Correction to recently added doxygen python test case
The _runme.py code for the recently added test case was using
references to an old module name for the test case, which was later
changed but not updated in the runme file.
2019-05-26 07:52:57 -05:00
John McFarland
0395c48124 Adjust expected python output for doxygen style2 test
Observed that with this second comment style, there is no line break
after the function overload headings in the translated
comments. Updating the test results accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
91a90b8d27 Adding test for second doxygen comment style
This style looks like:

/** Line 1
 *  Line 2
 */

This is needed to verify fixes to some of the indentation in the
translated comments.

The test is copied from doxygen_basic_translate.i.  One adjustment was
made to change the comment style on the last function that left out
the intermediate "*" characters.  This does not produce correct output
when combined with this style of starting the text on the first
comment line.

Test results are copied directly from doxygen_basic_translate.  A
minor difference in the Python results will be updated in a subsequent
commit.
2019-05-25 16:25:54 -05:00
John McFarland
08fc4a02b4 Eliminate extra newlines around doxygen python block math
Eliminate extra leading and trailing newlines around the \f[ and \f{
block math commands for doxygen comment translation for python.
Update tests accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
c52bed2e66 Eliminate extra newlines in doxygen python \verbatim blocks
Eliminate extra leading and trailing newlines present in translated
doxygen \verbatim comments for python.  Updating doxygen python tests
accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
321cb096a8 Remove extra newline from end of doxygen python \code command
Remove the extra newline at the end of translation of doxygen \code
\endcode command for Python.  Update test output accordingly.
2019-05-25 16:25:54 -05:00
John McFarland
3d64a2c037 Remove extra newline in beginning of doxygen python \code command
If \code is used as a block command (probably the main use case), an
extra newline was included in the translated Python comments.  This is
now removed and doxygen python test case output updated.
2019-05-25 16:14:02 -05:00
John McFarland
e62c88883f Fix python doxygen indentation for inline \code command
If \code was used inline, it produced an extra indent versus block
usage.  This extra indent was also stored in the test output.  This
update resolves this by simply removing a space that was being added
unnecessarily in handleTagVerbatim.  Updating test case output
accordingly.
2019-05-25 16:11:20 -05:00
William S Fulton
cedf4a2c2f More python std::list testing 2019-03-25 18:54:08 +00:00
William S Fulton
826f1448b8 Fix Python low-level static member setters.
The low-level API for setting static member variables stopped working
when the fastunpack option was turned on by default. The PyMethodDef
setup requires METH_O, not METH_VARARGS with fastunpack.
2019-03-20 21:44:34 +00:00
William S Fulton
2bb5eeef91 Improve Python static member variable testing
Double check the values are being set in the C++ layer via a function call to C++ layer.
2019-03-20 21:10:28 +00:00
William S Fulton
bc0645ce2b Merge branch 'ZackerySpytz-director-classes-final-methods'
* ZackerySpytz-director-classes-final-methods:
  Warning tweaks for destructors that are final in director classes
  Documentation for directors and virtual final methods
  Fixes for final destructors in director classes
  Warning fix for final destructor in directors
  Remove a useless warning filter
  Fix the handling of director classes with final methods
2019-03-03 15:12:53 +00:00
William S Fulton
83ea2280e2 Fix Python compile errors with overloading and varargs
Fixes wrapping overloaded functions/constructors where a vararg
function is declared after a non-vararg function.
This is a long standing bug in the Python layer exposed since fastunpack
was turned on by default.
2019-02-25 19:27:23 +00:00
Zackery Spytz
c3d652c785 Fix the handling of director classes with final methods
Generated SwigDirector_* classes were attempting to override
methods marked as final.

In addition, give a warning if the destructor of a director class is
final.

Closes #564.
2019-02-22 06:28:53 -07:00
William S Fulton
1f46d9b7b9 Fix regression parsing gcc preprocessor linemarkers
These are preprocessor statement in the form:

 # linenum filename flags

Closes #1475
2019-02-19 21:32:04 +00:00
William S Fulton
9038a9987d Add std::vector back reference test 2019-02-18 21:39:17 +00:00
William S Fulton
b0f105fa9f
Merge branch 'master' into cpp17-hexadecimal-floating-literals 2019-02-15 18:57:25 +00:00
William S Fulton
e26f6bb4e2 Add missing typedefs to std::vector + typedef corrections
Tests for std::vector of pointers added which check
 std::vector<T*>::const_reference and std::vector<T*>::reference
usage which gave compilation errors in Python and Perl which had
specialized these vectors incorrectly.
2019-02-13 22:46:28 +00:00
William S Fulton
1f44997343 rename std::array testcase 2019-02-13 22:46:20 +00:00
Zackery Spytz
cf83adfcd1 Add support for C++17 hexadecimal floating literals 2019-02-13 15:16:40 -07:00
William S Fulton
be84fc62a9 Merge branch 'ZackerySpytz-cpp14-binary-integer-literals'
* ZackerySpytz-cpp14-binary-integer-literals:
  Add support for C++14 binary integer literals
2019-02-11 18:36:47 +00:00
Vadim Zeitlin
ddf4bbe112 Merge branch 'fix-ignore-param'
Fix for wrongly renaming parameters to "$ignore" in Python.

See https://github.com/swig/swig/pull/1462
2019-02-11 14:24:46 +01:00
Zackery Spytz
23d83cd9c1 Add support for C++14 binary integer literals
Closes #1030.
2019-02-10 15:38:49 -07:00
Zackery Spytz
e4759ae250 C++17 u8 character literals testcase
Issue #1450
2019-02-10 15:53:42 +00:00
Vadim Zeitlin
2517f5b05e Don't apply %ignore to parameters
Fix regression introduced by 3f5c17824c
which resulted in using "$ignore" instead of the real parameter name in
Python if an %ignore/%rename($ignore) for the parameter name was used
(as could happen not necessarily intentionally when using wild card
ignores with regex matches) by explicitly checking if we're dealing with
a parameter node in apply_rename(), used by Swig_name_make(), and not
renaming it to "$ignore" in this case.

Extend the test suite to check for this case.

Closes #1460.
2019-02-10 13:40:12 +01:00
Vadim Zeitlin
509b14ac6f Add Python run-time test for ignore_parameter.i
This will allow to test the upcoming fix for wrongly handling "%ignore"
for parameters in the test suite.
2019-02-10 13:31:54 +01:00
Alec Woods
98023054c6 Properly handle destructors as methods for autodoc and fix some stray newlines 2019-01-26 09:30:26 -05:00
Alec Woods
5106573b29 Fixing docstrings for variables and static functions for consistency 2019-01-26 09:30:26 -05:00
Alec Woods
86e08c8e34 Fixes so that fastproxy and autodoc work correctly with both low-level C API and high-level Python Shadow API 2019-01-26 09:30:26 -05:00
Alec Woods
fb58727135 Also check documentation on the low-level API 2019-01-26 09:30:26 -05:00
Alec Woods
591a70378e Fixing python docstring handling for -fastproxy 2019-01-26 09:30:26 -05:00
Vadim Zeitlin
1e22e791ef Always include default parameter values in Python autodoc strings
One of side effects of 15b369028f was that
the default values were only included in Python doc strings if we could
be sure that they could be interpreted as valid Python expressions, but
this change was actually undesirable as it may be useful to see C++
expression for the default value in the doc string even when it isn't
valid in Python.

Undo this part of the change and extend autodoc unit test to check that
this stays fixed.

Closes #1271.
2019-01-21 00:57:02 +01:00
William S Fulton
721f6ddef1 Add autodoc and keyword argument tests 2019-01-19 19:52:40 +00:00
William S Fulton
2e9b270cbb Merge branch 'vadz-better-param-names'
* vadz-better-param-names:
  Enable keyword arguments for keyword_rename unit test
  Update error messages test suite
  Add more tests for Python parameter renaming
  Improve handling parameters clashing with language keywords
2019-01-17 18:19:36 +00:00
William S Fulton
1bd1142d02 Fix python callback test-suite failure 2019-01-16 20:10:37 +00:00
William S Fulton
cf1624ebc4 Python static method wrapper changes
- Static method wrappers were using the 'fastproxy' approach by default.
  This is inconsistent with instance method wrappers. The fastproxy approach
  is now turned off by default to be consistent with instance methods.
  Static method wrappers can now also be controlled using the -fastproxy and
  -olddefs options.

  Example:

    struct Klass {
      static int statmethod(int a = 2);
    };

  generates:

  class Klass(object):
      ...
      @staticmethod
      def statmethod(a=2):
          return _example.Klass_statmethod(a)

  instead of:

    class Klass(object):
      ...
      statmethod = staticmethod(_example.Klass_statmethod)

- Modernise wrappers for static methods to use decorator syntax - @staticmethod.

- Add missing runtime test for static class methods and using the actual
  class method.
2019-01-16 08:21:00 +00:00