Commit Graph

39 Commits

Author SHA1 Message Date
William S Fulton cf8788c411 Update Python tests to not use flatstaticmethod access
Use Python class staticmethod syntax to access C++ static member functions,
such as Klass.memberfunction, instead of Klass_memberfunction.
Examples and test-suite changes in preparation for issue #2137.
2022-01-14 22:48:11 +00:00
Vadim Zeitlin e14532ce52 Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.

Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.

Closes #1648.
2020-01-30 16:11:18 +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
Vadim Zeitlin 22158807fa Add more tests for Python parameter renaming
These tests were proposed by @wsfulton.

See https://github.com/swig/swig/issues/1272
2019-01-16 04:29:04 +01:00
Olly Betts 728b8955bd Drop support for Python classic classes
There were only needed to support Python < 2.2, and we now require at
least Python 2.6.

 Conflicts:
	.travis.yml
	Examples/test-suite/python/autodoc_runme.py
	Source/Modules/python.cxx

This is a cherry-pick and merge from patch in #1261
2018-10-12 07:10:47 +01:00
William S Fulton c9cac931c7 Re-implement Python -fastproxy option.
The previous implementation failed with Python 3 and abstract base clases.
The new implementation replaces the Python 2 implementation using new.instancemethod with C API PyMethod_New to match the equivalent Python 3 implementation which uses PyInstanceMethod_New.

Closes #1310
2018-08-18 00:36:23 +01:00
William S Fulton 95caf87596 PEP8 conformance for comment verifier module 2018-05-25 07:56:45 +01:00
Vadim Zeitlin db65ae5aea Merge branch 'master' into doxygen
Fix the usual conflicts in autodoc unit test due to fixing the
divergences in autodoc generation between builtin and default cases in
this branch.
2017-09-19 14:02:53 +02:00
William S Fulton 7be6c10d4a Fix display of documented template types when using the autodoc feature for Python. 2017-07-07 19:35:44 +01:00
Vadim Zeitlin e668c47b70 Merge branch 'master' into doxygen
The way Python docstrings are indented has changed on master, so use the
standard inspect module in Python autodoc unit test to ignore the differences
in their indentation level between -builtin and non-builtin cases to make the
test still pass with the branch version, which avoids the use of different
(but almost identical) values in the test itself.
2016-12-12 01:24:17 +01:00
William S Fulton 86fd5c9858 Fix autodoc testcase for python -fastproxy
Also fixes -O.
This is a minimal change avoiding the differences in the function names
when -fastproxy is used until autodoc code is improved with doxygen
changes.

Closes #721.
2016-06-22 00:15:05 +01:00
Olly Betts 8ab622c6d0 [Python] Fix docstrings for %callback functions
Reinstates autodoc for callback function testcase from #467, actually
tests the resulting docstring in the _runme.py and fixes SWIG/Python
so the expected result is obtained.
2015-09-04 13:04:37 +12:00
xantares 92328a2016 pep257 & numpydoc conforming docstrings 2015-08-07 22:15:13 +01:00
Vadim Zeitlin e191360c9f Merge "-builtin" autodoc bugs workarounds from master into test.
Although some of the bugs (e.g. missing "self") in the autodoc doc strings
when using "-builtin" option were fixed in the Doxygen branch, others are
still present, so we still need to skip some of the tests in "-builtin" case.
2015-07-20 16:17:06 +02:00
Vadim Zeitlin 302955a152 Another merge with master.
Updated Doxygen error numbers yet again, as Python errors got added in the
meanwhile, pushing the Doxygen ones further off.

And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again
(if anybody is looking for a motivating example about why significant
whitespace is bad, here is a great use case).
2015-07-20 00:44:26 +02:00
Jon Schlueter b77f3afafb autopep8 cleanup of Examples/test-suite/python
automated cleanup of python pep8 whitespace compliance
2015-05-08 21:35:52 -04:00
Vadim Zeitlin 300ccce46c Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was
taken by Scilab in the meanwhile.

Resolve conflicts in autodoc_runme.py once again.
2015-02-16 23:46:39 +01:00
William S Fulton f1213809a2 Fix python tests for old versions of Python 2015-01-31 17:39:36 +00:00
William S Fulton 76bcec1d87 Test-suite fixes for python -classic
These are mostly workarounds for static class members not being supported for
old style classes, as documented in Python.html, "C++ classes".
2015-01-31 15:04:35 +00:00
Vadim Zeitlin fd47e6870e Fix autodoc strings generated in Python builtin case and the test.
Use the proper AUTODOC_METHOD for autodoc strings generation when using
"-builtin", there is no reason to use AUTODOC_FUNC here when AUTODOC_METHOD is
used by default (i.e. without "-builtin").

This allows to (almost) stop differentiating between the two cases in the
autodoc unit test, allowing to simplify it significantly.

Also fix this test to pass after the recent changes removing docstring
indentation in the generated code.
2014-12-15 20:27:46 +01:00
Vadim Zeitlin 9b857e6cf1 Merge latest master into doxygen branch. 2014-12-15 02:55:26 +01:00
William S Fulton fc1eaa5213 Fix autodoc testcase for python -builtin 2014-10-29 12:23:51 +00:00
William S Fulton 5d71f91b29 Fix autodoc testcase for new named python arguments when using python -builtin
For the changes in #201.
2014-10-28 07:07:00 +00:00
William S Fulton ef4d44e92d Fix syntax error in autodoc testcase when using Python 2.4 and earlier 2014-10-10 23:56:14 +01:00
William S Fulton 185d65895f Bypass Python tests not supported by -builtin
There are a number of autodoc comment differences when using -builtin.
Some of which might need fixing, but for now we'll accept them as they
are.
2014-10-07 20:58:39 +01:00
Vadim Zeitlin 16548cced0 Simplify and make more efficient building Python docstrings.
Make the rules for combining explicitly specified docstring, autodoc one and
the one obtained by translating Doxygen comments implicit in the structure of
the code itself instead of writing complicated conditions checking them.

This results in small changes to the whitespace in the generated Python code
when using autodoc, but this makes it PEP 8-compliant, so it is the right
thing to do anyhow.

Also cache the docstring built from translated Doxygen comments. The existing
code seemed to intend to do it, but didn't, really. This helps with
performance generally speaking (-10% for a relatively big library using a lot
of Doxygen comments) and also makes debugging Doxygen translation code less
painful as it's executed only once instead of twice for each comment.

Finally, avoid putting "r", used for Python raw strings, into docstrings in C
code, it is really not needed there.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin 1ebd2334b8 Merge branch 'master' into doxygen
Merge with ~3.0.1 sources from master.
2014-04-30 18:37:57 +02:00
William S Fulton 074c0039db Fix Python version checking in Python tests 2013-05-24 18:57:26 +01:00
William S Fulton 5878ca5f1a Fix autodoc test for python 2.4 2013-03-29 09:20:17 +00: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
Dmitry Kabak 72b23954fb Fix integration of doxygen with autodoc feature, fixed autodoc test and some code refactored
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13183 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-18 18:33:30 +00:00
William S Fulton 117cb9b74a Fix a few warnings/errors in the test-suite using Solaris compiler
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12993 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-15 21:56:38 +00:00
William S Fulton 3243cbaad4 Numerous autodoc fixes for Python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12735 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-06-10 19:33:40 +00:00