Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

add default parameter support #53

Merged
merged 2 commits into from
Dec 9, 2019

Conversation

cryoma01
Copy link

Since Qt5.12, Qt QML module supports ECMAScript 7 (https://doc.qt.io/qt-5/whatsnew512.html). This includes an upgrade to ECMAScript 6 which includes handling of default parameters values (http://es6-features.org/#DefaultParameterValues).

The goal of this pull request is to fix the error raised by doxyqml when parsing QML with default parameters values.

@coveralls
Copy link

coveralls commented Nov 29, 2019

Pull Request Test Coverage Report for Build 113

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 15 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.05%) to 89.379%

Files with Coverage Reduction New Missed Lines %
/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/doxyqml-0.5.0-py3.5.egg/doxyqml/qmlparser.py 7 92.09%
/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/doxyqml-0.5.0-py3.5.egg/doxyqml/qmlclass.py 8 95.56%
Totals Coverage Status
Change from base Build 104: 0.05%
Covered Lines: 2188
Relevant Lines: 2448

💛 - Coveralls

Copy link
Owner

@agateau agateau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor remarks, but looks good overall, thanks for your work!

Can you look at the coverage decrease? I just realized the coverage report does not let one see the missing lines, going to fix this.

@@ -207,12 +212,18 @@ def consume_wo_comments(self):
if not is_comment_token(token):
return token

def consume_expecting(self, type, value=None):
def consume_expecting(self, expect_type, value=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since expect_type can also be a list I would rename it expected_types.

if token.type != type:
raise QmlParserError("Expected token of type '%s', got '%s' instead" % (type, token.type), token)
if type(expect_type) is list:
if not (token.type in expect_type):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be more pythonic:

Suggested change
if not (token.type in expect_type):
if token.type not in expected_types:

Comment on lines 40 to 57
/**
* Function with int default parameter
* @param arg A parameter with a defaultvalue
* @return the result
*/
int intDefaultParameter(int arg);
/**
* Function with string default parameter
* @param arg A parameter with a default value
* @return the result
*/
string stringDefaultParameter(string arg);
/**
* Function with property as default parameter
* @param arg A parameter with a default value
* @return the result
*/
int propDefaultParameter(int arg);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect the produced C++ function declarations would contain the default values. Is this something you plan to do? (not mandatory for now: making the parser not confused with default values is already nice)

@agateau
Copy link
Owner

agateau commented Dec 9, 2019

Looks great, thanks!

@agateau agateau merged commit edf31ea into agateau:master Dec 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants