Skip to content

Commit 2bbacb6

Browse files
authoredMay 23, 2018
Merge pull request #7054 from nyalldawson/compliant
Add compliance test to doxygen test
2 parents e6c9498 + afa04d9 commit 2bbacb6

File tree

6 files changed

+60
-18
lines changed

6 files changed

+60
-18
lines changed
 

‎python/gui/auto_generated/editorwidgets/core/qgseditorwidgetwrapper.sip.in

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,33 +187,34 @@ Add a hint text on the widget
187187

188188
ConstraintResult constraintResult() const;
189189
%Docstring
190-
Getter of constraintResult
191-
It's the current result of the constraint on the widget influencing it's visualization.
190+
Returns the constraint result, which is the current result of the constraint
191+
on the widget influencing its visualization.
192192

193193
.. versionadded:: 3.0
194194
%End
195195

196196
bool constraintResultVisible() const;
197197
%Docstring
198-
Getter of constraintResultVisible
199-
Defines if the constraint result should be visualized on the widget (with color).
198+
Returns whether the constraint result is visible.
199+
200+
Returns true if the constraint result will be visualized on the widget (with color).
200201
This will be disabled when the form is not editable.
201202

202203
.. versionadded:: 3.0
203204
%End
204205

205206
void setConstraintResultVisible( bool constraintResultVisible );
206207
%Docstring
207-
Setter of constraintResultVisible
208-
Defines if the constraint result should be visualized on the widget (with color).
208+
Sets whether the constraint result is visible.
209+
210+
Controls if the constraint result should be visualized on the widget (with color).
209211
This will be disabled when the form is not editable.
210212

211213
:param constraintResultVisible: if constraintResult should be displayed (mostly editable status)
212214

213215
.. versionadded:: 3.0
214216
%End
215217

216-
217218
signals:
218219

219220
void valueChanged( const QVariant &value );

‎python/gui/auto_generated/qgsattributetypeloaddialog.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Sets predefined vector layer for selection of data
3535

3636
QMap<QString, QVariant> &valueMap();
3737
%Docstring
38-
Getter to value map which is currently active
38+
Returns the value map which is currently active.
3939

4040
:return: value map of vlues selected from layer
4141
%End

‎src/gui/editorwidgets/core/qgseditorwidgetwrapper.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,30 +190,34 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
190190
virtual void setHint( const QString &hintText );
191191

192192
/**
193-
* Getter of constraintResult
194-
* It's the current result of the constraint on the widget influencing it's visualization.
193+
* Returns the constraint result, which is the current result of the constraint
194+
* on the widget influencing its visualization.
195+
*
195196
* \since QGIS 3.0
196197
*/
197198
ConstraintResult constraintResult() const;
198199

199200
/**
200-
* Getter of constraintResultVisible
201-
* Defines if the constraint result should be visualized on the widget (with color).
201+
* Returns whether the constraint result is visible.
202+
*
203+
* Returns true if the constraint result will be visualized on the widget (with color).
202204
* This will be disabled when the form is not editable.
205+
*
203206
* \since QGIS 3.0
204207
*/
205208
bool constraintResultVisible() const;
206209

207210
/**
208-
* Setter of constraintResultVisible
209-
* Defines if the constraint result should be visualized on the widget (with color).
211+
* Sets whether the constraint result is visible.
212+
*
213+
* Controls if the constraint result should be visualized on the widget (with color).
210214
* This will be disabled when the form is not editable.
215+
*
211216
* \param constraintResultVisible if constraintResult should be displayed (mostly editable status)
212217
* \since QGIS 3.0
213218
*/
214219
void setConstraintResultVisible( bool constraintResultVisible );
215220

216-
217221
signals:
218222

219223
/**

‎src/gui/qgsattributetypeloaddialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class GUI_EXPORT QgsAttributeTypeLoadDialog: public QDialog, private Ui::QgsAttr
5252
void setVectorLayer( QgsVectorLayer *layer );
5353

5454
/**
55-
* Getter to value map which is currently active
55+
* Returns the value map which is currently active.
56+
*
5657
* \returns value map of vlues selected from layer
5758
*/
5859
QMap<QString, QVariant> &valueMap();

‎tests/code_layout/doxygen_parser.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, path, acceptable_missing={}, acceptable_missing_added_note=[]
5252
self.documentable_members = 0
5353
self.documented_members = 0
5454
self.undocumented_members = {}
55+
self.noncompliant_members = {}
5556
self.bindable_members = []
5657
self.groups = {}
5758
self.classes_missing_group = []
@@ -140,7 +141,7 @@ def parseFile(self, f):
140141
if event == 'end' and elem.tag == 'compounddef':
141142
if self.elemIsPublicClass(elem):
142143
# store documentation status
143-
members, documented, undocumented, bindable, has_brief_description, found_version_added = self.parseClassElem(elem)
144+
members, documented, undocumented, noncompliant, bindable, has_brief_description, found_version_added = self.parseClassElem(elem)
144145
documentable_members += members
145146
documented_members += documented
146147
class_name = elem.find('compoundname').text
@@ -168,6 +169,9 @@ def parseFile(self, f):
168169
self.undocumented_members[class_name]['members'] = members
169170
self.undocumented_members[class_name]['missing_members'] = unacceptable_undocumented
170171

172+
if len(noncompliant) > 0:
173+
self.noncompliant_members[class_name] = noncompliant
174+
171175
# store bindable members
172176
if self.classElemIsBindable(elem):
173177
for m in bindable:
@@ -224,6 +228,7 @@ def parseClassElem(self, e):
224228
documentable_members = 0
225229
documented_members = 0
226230
undocumented_members = set()
231+
noncompliant_members = []
227232
bindable_members = []
228233
# loop through all members
229234
for m in e.getiterator('memberdef'):
@@ -238,6 +243,9 @@ def parseClassElem(self, e):
238243
documentable_members += 1
239244
if self.memberIsDocumented(m):
240245
documented_members += 1
246+
error = self.memberDocIsNonCompliant(m)
247+
if error:
248+
noncompliant_members.append({m.find('name').text: error})
241249
else:
242250
undocumented_members.add(signature)
243251
# test for brief description
@@ -259,7 +267,7 @@ def parseClassElem(self, e):
259267
if found_version_added:
260268
break
261269

262-
return documentable_members, documented_members, undocumented_members, bindable_members, has_brief_description, found_version_added
270+
return documentable_members, documented_members, undocumented_members, noncompliant_members, bindable_members, has_brief_description, found_version_added
263271

264272
def memberSignature(self, elem):
265273
""" Returns the signature for a member
@@ -537,3 +545,23 @@ def memberIsDocumented(self, member_elem):
537545
if doc is not None and list(doc):
538546
return True
539547
return False
548+
549+
def memberDocIsNonCompliant(self, member_elem):
550+
""" Tests whether an member's documentation is non-compliant
551+
:param member_elem: XML element for a class member
552+
"""
553+
for doc_type in ['briefdescription']:
554+
doc = member_elem.find(doc_type)
555+
if doc is not None:
556+
for para in doc.getiterator('para'):
557+
if not para.text:
558+
continue
559+
if para.text.strip().lower().startswith('getter'):
560+
return 'Use "Returns the..." instead of "getter"'
561+
elif para.text.strip().lower().startswith('setter'):
562+
return 'Use "Sets the..." instead of "setter"'
563+
#elif para.text.strip().lower().startswith('return '):
564+
# return 'Use "Returns the..." instead of "return ..."'
565+
#elif para.text.strip().lower().startswith('set '):
566+
# return 'Use "Sets the..." instead of "set ..."'
567+
return False

‎tests/code_layout/test_qgsdoccoverage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def testCoverage(self):
6060
for mem in props['missing_members']:
6161
print((colored(' "' + mem + '"', 'yellow', attrs=['bold'])))
6262

63+
if parser.noncompliant_members:
64+
for cls, props in list(parser.noncompliant_members.items()):
65+
print(('\n\nClass {}, non-compliant members found\n'.format(colored(cls, 'yellow'))))
66+
for p in props:
67+
for mem, error in p.items():
68+
print((colored(' ' + mem + ': ' + error, 'yellow', attrs=['bold'])))
69+
6370
# self.assertEquals(len(parser.undocumented_string), 0, 'FAIL: new undocumented members have been introduced, please add documentation for these members')
6471

6572
if parser.classes_missing_group:
@@ -88,6 +95,7 @@ def testCoverage(self):
8895
self.assertTrue(not parser.classes_missing_group, 'Classes without \\group tag found')
8996
self.assertTrue(not parser.classes_missing_version_added, 'Classes without \\since version tag found')
9097
self.assertTrue(not parser.classes_missing_brief, 'Classes without \\brief description found')
98+
self.assertTrue(not parser.noncompliant_members, 'Non compliant members found')
9199

92100

93101
if __name__ == '__main__':

0 commit comments

Comments
 (0)
Please sign in to comment.