Skip to content

Commit

Permalink
Add unit test to prevent deprecated methods without description
Browse files Browse the repository at this point in the history
And add missing descriptions
  • Loading branch information
nyalldawson committed May 25, 2018
1 parent 8bb45b9 commit 5e360f9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
3 changes: 2 additions & 1 deletion python/core/auto_generated/qgsproject.sip.in
Expand Up @@ -110,7 +110,8 @@ Returns QFileInfo object for the project's associated file.
.. seealso:: :py:func:`fileName`

.. versionadded:: 2.9
\deprecated

.. deprecated:: Use absoluteFilePath(), baseName() or lastModifiedTime() instead
%End

QgsProjectStorage *projectStorage() const;
Expand Down
Expand Up @@ -138,28 +138,28 @@ Sort this model by its display expression.
%Docstring
Does nothing except for calling beginRemoveRows()

\deprecated
.. deprecated:: Use beginRemoveRows() instead
%End

void onEndRemoveRows( const QModelIndex &parent, int first, int last );
%Docstring
Does nothing except for calling endRemoveRows()

\deprecated
.. deprecated:: Use endRemoveRows() instead
%End

void onBeginInsertRows( const QModelIndex &parent, int first, int last );
%Docstring
Does nothing except for calling beginInsertRows()

\deprecated
.. deprecated:: use beginInsertRows() instead
%End

void onEndInsertRows( const QModelIndex &parent, int first, int last );
%Docstring
Does nothing except for calling endInsertRows()

\deprecated
.. deprecated:: use endInsertRows() instead
%End

};
Expand Down
3 changes: 2 additions & 1 deletion python/gui/auto_generated/qgisinterface.sip.in
Expand Up @@ -859,7 +859,8 @@ QGIS documentation, set useQgisDocDirectory to false.
:param url: URL to open
:param useQgisDocDirectory: If true, the URL will be formed by concatenating
url to the QGIS documentation directory path (prefix/share/doc)
\deprecated

.. deprecated:: Use QDesktopServices instead
%End

virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false, bool showModal = true ) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Expand Up @@ -158,7 +158,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*
* \see fileName()
* \since QGIS 2.9
* \deprecated
* \deprecated Use absoluteFilePath(), baseName() or lastModifiedTime() instead
*/
Q_DECL_DEPRECATED QFileInfo fileInfo() const SIP_DEPRECATED;

Expand Down
8 changes: 4 additions & 4 deletions src/gui/attributetable/qgsfeaturelistmodel.h
Expand Up @@ -143,28 +143,28 @@ class GUI_EXPORT QgsFeatureListModel : public QSortFilterProxyModel, public QgsF
/**
* Does nothing except for calling beginRemoveRows()
*
* \deprecated
* \deprecated Use beginRemoveRows() instead
*/
Q_DECL_DEPRECATED void onBeginRemoveRows( const QModelIndex &parent, int first, int last );

/**
* Does nothing except for calling endRemoveRows()
*
* \deprecated
* \deprecated Use endRemoveRows() instead
*/
Q_DECL_DEPRECATED void onEndRemoveRows( const QModelIndex &parent, int first, int last );

/**
* Does nothing except for calling beginInsertRows()
*
* \deprecated
* \deprecated use beginInsertRows() instead
*/
Q_DECL_DEPRECATED void onBeginInsertRows( const QModelIndex &parent, int first, int last );

/**
* Does nothing except for calling endInsertRows()
*
* \deprecated
* \deprecated use endInsertRows() instead
*/
Q_DECL_DEPRECATED void onEndInsertRows( const QModelIndex &parent, int first, int last );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgisinterface.h
Expand Up @@ -698,7 +698,7 @@ class GUI_EXPORT QgisInterface : public QObject
* \param url URL to open
* \param useQgisDocDirectory If true, the URL will be formed by concatenating
* url to the QGIS documentation directory path (prefix/share/doc)
* \deprecated
* \deprecated Use QDesktopServices instead
*/
#ifndef Q_MOC_RUN
Q_DECL_DEPRECATED
Expand Down
7 changes: 7 additions & 0 deletions tests/code_layout/doxygen_parser.py
Expand Up @@ -527,18 +527,25 @@ def isDeprecated(self, member_elem):
pass

doxy_deprecated = False
has_description = True
try:
for p in member_elem.find('detaileddescription').getiterator('para'):
for s in p.getiterator('xrefsect'):
if s.find('xreftitle') is not None and 'Deprecated' in s.find('xreftitle').text:
doxy_deprecated = True
if s.find('xrefdescription') is None or s.find('xrefdescription').find('para') is None:
has_description = False
break
except:
assert 0, member_elem.find('definition').text

if not decl_deprecated and not doxy_deprecated:
return False

if doxy_deprecated and not has_description:
assert has_description, 'Error: Missing description for deprecated method {}'.format(
member_elem.find('definition').text)

# only functions for now, but in future this should also apply for enums and variables
if member_elem.get('kind') in ('function', 'variable'):
assert decl_deprecated, 'Error: Missing Q_DECL_DEPRECATED for {}'.format(member_elem.find('definition').text)
Expand Down

0 comments on commit 5e360f9

Please sign in to comment.