Re: %feature("docstring") syntax
"Seth G" <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
Thanks William.
I had started to experiment with the doxygen support. Initially I thought it didn't work as I was also using the %feature("autodoc") feature which overrides it, but I see this may be changed in the 4.1 release - https://github.com/swig/swig/issues/1635
The doxygen approach is much cleaner and avoids lots of SWIG directives in header files etc. to add documents to properties.
Are there any disadvantages of doxygen over %feature("docstring") ?
As I understand it the former works for Python and Java, and the latter for Python and Ruby.
Seth
--
web:http://geographika.co.uk
twitter: @geographika
On Sun, Jun 14, 2020, at 12:31 AM, William S Fulton wrote:
> Consider using the doxygen comment support then (-doxygen option). Then you could simply have:
>
> /** Adjust the rect to fit the width and height. Returns cellsize of rect. */
> double fit(int width, int height) {
> return msAdjustExtent(self, width, height);
> }
>
>
> > %feature("docstring", "A docstring in the brackets") myFunction
>
> This above is invalid syntax as it is missing the trailing semicolon.
>
> William
>
>
> On Sat, 13 Jun 2020 at 10:54, Seth G <[email protected]> wrote:
>> Hi all,
>>
>> Not sure how I missed it - details are given in http://www.swig.org/Doc4.0/SWIGDocumentation.html#Customization_features
>>
>> The %feature directive can be used with different syntax. The following are all equivalent:
>>
>> %feature("except") Object::method { $action };
>> %feature("except") Object::method %{ $action %};
>> %feature("except") Object::method " $action ";
>> %feature("except", "$action") Object::method;
>>
>> So using the following syntax:
>>
>> %feature("docstring")
>> "Adjust the rect to fit the width and height. Returns cellsize of rect."
>> double fit(int width, int height) {
>> return msAdjustExtent(self, width, height);
>> }
>>
>> Adds the docstring to the "fit" function, but then needs to be cleared afterwards or it will apply to all following functions.
>> I believe the correct syntax should be:
>>
>> %feature("docstring") fit
>> "Adjust the rect to fit the width and height. Returns cellsize of rect.";
>> double fit(int width, int height) {
>> return msAdjustExtent(self, width, height);
>> }
>>
>> It would be nice to be able to attach the docstring without having to repeat the function name declared immediately afterwards.
>>
>> Seth
>>
>> --
>> web:http://geographika.co.uk
>> twitter: @geographika
>>
>> On Mon, Jun 8, 2020, at 10:13 PM, Seth G wrote:
>> > Hi all,
>> >
>> > A quick question on the syntax for %feature("docstring"). From the docs
>> > at http://www.swig.org/Doc4.0/Python.html#Python_nn71
>> >
>> > "In addition to the autodoc strings described above, you can also
>> > attach any arbitrary descriptive text to a node in the parse tree with
>> > the "docstring" feature. "
>> >
>> > Most of the SWIG tests use the following syntax:
>> >
>> > %feature("docstring") MyObject::x "float The x value.";
>> >
>> > However the simply adding a docstring prior to a function also seems to
>> > produce the correct output:
>> >
>> > %feature("docstring")
>> > "Adjust the rect to fit the width and height. Returns cellsize of rect."
>> > double fit(int width, int height) {
>> > return msAdjustExtent(self, width, height);
>> > }
>> >
>> > In a search on GitHub I've also seen the following form:
>> >
>> > %feature("docstring", "A docstring in the brackets") myFunction
>> >
>> > And also sometimes there are semicolons at the end and sometimes not.
>> >
>> > Are all the above examples valid?
>> > I'm happy to expand the docs with a pull request if anyone can provide
>> > clarifications.
>> > Thanks,
>> >
>> > Seth
>>
>> > --
>> > web:http://geographika.co.uk
>> > twitter: @geographika
>> >
>> >
>> > _______________________________________________
>> > Swig-user mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/swig-user
>> >
>>
>>
>> _______________________________________________
>> Swig-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/swig-user
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user