Navigation Menu

Skip to content

Commit

Permalink
Add test for coverage of SIP bindings
Browse files Browse the repository at this point in the history
Not perfect, but good for a quick warning if a new class or member
has been added to the public API without Python bindings. The test
only considers the name of members, since it seems to be impossible
to test for the signature of a Python member. (So adding a new
overloaded method without bindings will still unfortunately pass).

You can avoid the test where bindings are not applicable:
- for a whole class by placing "@note not available in Python bindings"
in the class' Doxygen comments
- or by placing the @note inside a member's Doxygen comments for a
specific member

Additionally, classes which aren't included in the API docs
will not be tested.
  • Loading branch information
nyalldawson committed Oct 27, 2015
1 parent 7842391 commit fc49f8d
Show file tree
Hide file tree
Showing 18 changed files with 493 additions and 174 deletions.
4 changes: 4 additions & 0 deletions python/core/effects/qgspainteffectregistry.sip
Expand Up @@ -69,6 +69,10 @@ class QgsPaintEffectRegistry

public:

/** Returns a reference to the singleton instance of the paint effect registry.
*/
static QgsPaintEffectRegistry* instance();

/** Returns the metadata for a specific effect.
* @param name unique string name for paint effect class
* @returns paint effect metadata if found, otherwise NULL
Expand Down
3 changes: 3 additions & 0 deletions python/gui/qgsfieldcombobox.sip
Expand Up @@ -44,4 +44,7 @@ class QgsFieldComboBox : QComboBox

//! setField sets the currently selected field
void setField( const QString& fieldName );

protected slots:
void indexChanged( int i );
};
3 changes: 3 additions & 0 deletions src/core/effects/qgspainteffectregistry.h
Expand Up @@ -154,6 +154,9 @@ class CORE_EXPORT QgsPaintEffectMetadata : public QgsPaintEffectAbstractMetadata
class CORE_EXPORT QgsPaintEffectRegistry
{
public:

/** Returns a reference to the singleton instance of the paint effect registry.
*/
static QgsPaintEffectRegistry* instance();

/** Returns the metadata for a specific effect.
Expand Down
4 changes: 4 additions & 0 deletions src/core/geometry/qgsgeos.cpp
Expand Up @@ -98,6 +98,10 @@ class GEOSInit

static GEOSInit geosinit;

/**
* @brief Scoped GEOS pointer
* @note not available in Python bindings
*/
class GEOSGeomScopedPtr
{
public:
Expand Down
9 changes: 8 additions & 1 deletion src/core/pal/costcalculator.h
Expand Up @@ -18,6 +18,11 @@
#include <QList>
#include "rtree.hpp"

/**
* \class pal::CostCalculator
* \note not available in Python bindings
*/

namespace pal
{
class Feats;
Expand Down Expand Up @@ -48,9 +53,11 @@ namespace pal
/**
* \brief Data structure to compute polygon's candidates costs
*
* eight segment from center of candidat to (rpx,rpy) points (0°, 45°, 90°, ..., 315°)
* Eight segments from center of candidate to (rpx,rpy) points (0°, 45°, 90°, ..., 315°)
* dist store the shortest square distance from the center to an object
* ok[i] is the to true whether the corresponding dist[i] is set
*
* \note not available in Python bindings
*/
class PolygonCostCalculator
{
Expand Down
7 changes: 7 additions & 0 deletions src/core/pal/feature.h
Expand Up @@ -41,6 +41,11 @@

#include "qgslabelingenginev2.h"

/**
* \class pal::LabelInfo
* \note not available in Python bindings
*/

namespace pal
{
/** Optional additional info about label (for curved labels) */
Expand Down Expand Up @@ -75,6 +80,8 @@ namespace pal

/**
* \brief Main class to handle feature
* \class pal::FeaturePart
* \note not available in Python bindings
*/
class CORE_EXPORT FeaturePart : public PointSet
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/pal/labelposition.h
Expand Up @@ -44,6 +44,8 @@ namespace pal

/**
* \brief LabelPosition is a candidate feature label position
* \class pal::LabelPosition
* \note not available in Python bindings
*/
class CORE_EXPORT LabelPosition : public PointSet
{
Expand Down
8 changes: 3 additions & 5 deletions src/core/pal/layer.h
Expand Up @@ -48,11 +48,9 @@ namespace pal
class LabelInfo;

/**
* \brief A layer of spacial entites
*
* a layer is a bog of feature with some data which influence the labelling process
*
* \author Maxence Laurent (maxence _dot_ laurent _at_ heig-vd _dot_ ch)
* \brief A set of features which influence the labelling process
* \class pal::Layer
* \note not available in Python bindings
*/
class CORE_EXPORT Layer
{
Expand Down
14 changes: 3 additions & 11 deletions src/core/pal/pal.h
Expand Up @@ -41,14 +41,6 @@

class QgsAbstractLabelProvider;

/**
*
* \section intro_sec Introduction
*
* Pal is a labelling library released under the GPLv3 license
*
*/

namespace pal
{
/** Get GEOS context handle to be used in all GEOS library calls with reentrant API */
Expand Down Expand Up @@ -101,12 +93,12 @@ namespace pal
};

/**
* \brief Pal main class.
* \brief Main Pal labelling class
*
* A pal object will contains layers and global information such as which search method
* will be used.
*
* \author Maxence Laurent (maxence _dot_ laurent _at_ heig-vd _dot_ ch)
* \class pal::Pal
* \note not available in Python bindings
*/
class CORE_EXPORT Pal
{
Expand Down
5 changes: 4 additions & 1 deletion src/core/pal/palstat.h
Expand Up @@ -36,8 +36,11 @@ namespace pal
{

/**
* Summury of problem
* \brief Summary statistics of labelling problem.
* \class pal::PalStat
* \note not available in Python bindings
*/

class PalStat
{

Expand Down
5 changes: 4 additions & 1 deletion src/core/pal/pointset.h
Expand Up @@ -56,7 +56,10 @@ namespace pal
double length;
} CHullBox;


/**
* \class pal::PointSet
* \note not available in Python bindings
*/
class CORE_EXPORT PointSet
{
friend class FeaturePart;
Expand Down
5 changes: 4 additions & 1 deletion src/core/pal/priorityqueue.h
Expand Up @@ -39,7 +39,10 @@

namespace pal
{

/**
* \class pal::PriorityQueue
* \note not available in Python bindings
*/
class PriorityQueue
{

Expand Down
8 changes: 7 additions & 1 deletion src/core/pal/problem.h
Expand Up @@ -41,6 +41,10 @@ namespace pal
class LabelPosition;
class Label;

/**
* \class pal::Sol
* \note not available in Python bindings
*/
class Sol
{
public:
Expand Down Expand Up @@ -88,7 +92,9 @@ namespace pal
} Chain;

/**
* \brief Represent a problem
* \brief Representation of a labeling problem
* \class pal::Problem
* \note not available in Python bindings
*/
class CORE_EXPORT Problem
{
Expand Down
1 change: 1 addition & 0 deletions src/core/pal/util.h
Expand Up @@ -46,6 +46,7 @@ namespace pal

/**
* \brief For usage in problem solving algorithm
* \note not available in Python bindings
*/
class Feats
{
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/CMakeLists.txt
Expand Up @@ -79,6 +79,8 @@ ENDIF (ENABLE_PGTEST)

IF (WITH_APIDOC)
ADD_PYTHON_TEST(PyQgsDocCoverage test_qgsdoccoverage.py)
#SIP coverage test relies on API doc parsing to identify members which should be in bindings
ADD_PYTHON_TEST(PyQgsSipCoverage test_qgssipcoverage.py)
ENDIF (WITH_APIDOC)

IF (WITH_SERVER)
Expand Down

1 comment on commit fc49f8d

@jef-n
Copy link
Member

@jef-n jef-n commented on fc49f8d Nov 1, 2015

Choose a reason for hiding this comment

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

fails on platforms that have don't have the QSci sip files installed and therefore have no bindings for (no HAVE_QSCI_SIP):

  • QgsCodeEditor
  • QgsCodeEditorPython

(Allegedly?) Missing methods

  • QgsIFeatureSelectionManager.selectionChanged
  • QgsVectorLayer.committedFeaturesRemoved
  • QgsVectorLayer.featuresDeleted
  • QgsVectorLayerEditBuffer.committedFeaturesRemoved

Please sign in to comment.