Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: "$TYPE" format keyword #23

Open
Naheulf opened this issue May 14, 2019 · 8 comments
Open

Enhancement: "$TYPE" format keyword #23

Naheulf opened this issue May 14, 2019 · 8 comments

Comments

@Naheulf
Copy link

Naheulf commented May 14, 2019

It would be nice if you add support for the "$TYPE" format keyword.

For "C", "C++", "Java" and "C#", types are part of the language and can be extracted following rules of each language.

For "Python" and "PHP" types should be extracted following respective types hints:

For "JavaScript" : /* no comment */

@dail8859
Copy link
Owner

I agree something like this would be useful, the problem it is very difficult to do correctly. Even now the code to parse out function names and parameters only works "well enough" most of the time.

You can quickly get into cases of:

def async_query(on_success: Callable[[int], None], on_error: Callable[[int, Exception], None]) -> None:

Which I haven't tried but probably fails to correctly pull out the two parameters currently.

To do it correctly would either involve complex regexes, string manipulation, and corner cases...or else something like a PEG which probably involves more time than I am willing to put into it. But someone else is very welcome to try to tackle this.

@WinterSilence
Copy link

@dail8859

Note that for PHP one can also specify the type (or types if you separate them with a pipe symbol) which are allowed for a parameter (as this is not part of the definition). The syntax is the same as for the phpDocumentor

http://www.doxygen.nl/manual/commands.html#cmdparam

@dail8859
Copy link
Owner

@WinterSilence Yes that adds yet another level of complexity which makes this feature that much more difficult to do correctly.

@WinterSilence
Copy link

WinterSilence commented May 30, 2019

@dail8859 what's problem? explode params by , adn parse params: /([^\$]*)\$([\w]+)/i
Also https://github.com/dail8859/DoxyIt/blob/master/src/Parsers/C_Parser.cpp#L24 failed when default value is array [] or array(), example.php:

Class Test {
  public function foo(array $options = []): string {
     return implode(', ', $options);
  }
}

@dail8859
Copy link
Owner

By all means please create a regex the properly parses out all the different parts of a function/method definition and I'll gladly incorporate it. My suspicion is it is easy to handle the simple cases but only using a regex alone wont be sufficient to handle complex cases.

@WinterSilence
Copy link

@dail8859 /([^\$]*)\$([\w]+)/i cover all cases for php. why u dont use Doxgen for parsing?

@dail8859
Copy link
Owner

why u dont use Doxgen for parsing?

I'm not sure what you mean by this.

@WinterSilence
Copy link

WinterSilence commented Jul 31, 2020

@dail8859

  1. I mean why you use part of code Doxygen? you can call it as application/library.
  2. Replace (\\$?\\w+|\\.\\.\\.)(\\s*=\\s*[\\\"\\w\\.']+)?\\s*[,)] to (\\$?\\w+|\\.\\.\\.)(\\s*=\\s*[^,)]+)?\\s*[,)] for cover more default values([]/['a' => 1, 'b' => "foo"], Class::CONSTANT, 'text'/"text").
  3. need something like input_filter to support filters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants