Yes, it's possible (you can add it as a feature request -- or you could submit a patch -- take a look at org.python.pydev.editor.correctionassist.docstrings.AssistDocString.java ).
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've looked into this class, but the problem is that I don't have any clue how to determine wether the current method returns a value or not. Can you give a hint where I should start searching?
Ciao,
Steffen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1. See where the scope of the current method ends. You can use org.python.pydev.parser.fastparser.FastParser#firstClassOrFunction to get where the next method / class starts -- the only catch is that you have to see the indent to see if it's not an inner function instead of a new scope.
2. Iterate lines from the current line that starts the scope to the end of it searching for 'return'. You have to do some text analysis here -- an AST could be generated, but in this case it's probably not appropriate, especially if you want to be more error prone, as ASTs usually require the code to be parseable (or have some minor errors which can be treated)
To iterate you can use the org.python.pydev.core.docutils.PyDocIterator (it helps skipping comments and literals)
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, on a second thought, to know the scope of this method you should probably analyze the indentation -- and create a helper method that does that -- because sometimes the next scope starts only after some globals, so, that heuristic wouldn't work.
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
would it be possible to include @return in the generated docstring for methods which return values?
Ciao,
Steffen
Yes, it's possible (you can add it as a feature request -- or you could submit a patch -- take a look at org.python.pydev.editor.correctionassist.docstrings.AssistDocString.java ).
Cheers,
Fabio
Hi,
I've looked into this class, but the problem is that I don't have any clue how to determine wether the current method returns a value or not. Can you give a hint where I should start searching?
Ciao,
Steffen
It should probably work something like:
1. See where the scope of the current method ends. You can use org.python.pydev.parser.fastparser.FastParser#firstClassOrFunction to get where the next method / class starts -- the only catch is that you have to see the indent to see if it's not an inner function instead of a new scope.
2. Iterate lines from the current line that starts the scope to the end of it searching for 'return'. You have to do some text analysis here -- an AST could be generated, but in this case it's probably not appropriate, especially if you want to be more error prone, as ASTs usually require the code to be parseable (or have some minor errors which can be treated)
To iterate you can use the org.python.pydev.core.docutils.PyDocIterator (it helps skipping comments and literals)
Cheers,
Fabio
Actually, on a second thought, to know the scope of this method you should probably analyze the indentation -- and create a helper method that does that -- because sometimes the next scope starts only after some globals, so, that heuristic wouldn't work.
Cheers,
Fabio