Commits

Matt Williams committed 6e7e504

More parsing tests into a proper test module.

Comments (0)

Files changed (5)

doxylink/doc/index.rst

 
 Doxylink is a Sphinx extension to link to external Doxygen API documentation.
 
-It works much like the extlinks extension but it does some more processing to link C++ symbols against their Doxygen HTML documentation.
+It allows you to specify C++ symbols and it will convert them into links to the HTML page of their Doxygen documentation.
 
 Usage
 -----
 
 	:polyvox:`Array <PolyVox::Array>`.
 	:polyvox:`PolyVox::Volume`
-	:qtogre:`QtOgre::Log`
-	:polyvox:`tidyUpMemory(int) <tidyUpMemory>`
+	You use :qtogre:`QtOgre::Log` to log events for the user.
+	:polyvox:`tidyUpMemory(int) <tidyUpMemory>` will reduce memory usage.
 	:polyvox:`PolyVox::Array::operator[]`
 
 Where ``polyvox`` and ``qtogre`` roles are defined by the :confval:`doxylink` configuration value.

doxylink/sphinxcontrib/parsing.py

 		return result.function_name, normalised_arg_list_string
 	
 	return None
-
-if __name__ == "__main__":
-	
-	samples = ['( const QXmlSchema & other )',
-	'( QUrl source )',
-	'( QUrl * source )',
-	'( QUrl ** source )',
-	'( const QUrl ** source )',
-	'( const QUrl source )',
-	'( QUrl & source )',
-	'( const QUrl & source )',
-	'( const QUrl * source )',
-	'( QIODevice * source, const QUrl & documentUri = QUrl() )',
-	'( const QByteArray & data, const QUrl & documentUri = QUrl() )',
-	'( const QAbstractMessageHandler * handler )',
-	'( QAbstractMessageHandler * handler )',
-	'(void)',
-	'(uint32_t uNoOfBlocksToProcess=(std::numeric_limits< uint32_t >::max)())',
-	'( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )',
-	'( const QPixmap & icon, bool recalc, bool redraw = true )',
-	'( const QString & text, bool recalc, bool redraw = true )',
-	'( const QString & foo, bool recalc, bool redraw = true )',
-	'( const QString & text, bool recalc, bool redraw=true )',
-	'( const QString & text, bool recalc, bool redraw )',
-	'( QUrl source, int foo, double bar )',
-	'()',
-	'( const QPixmap & pixmap, const QString & text, int index = -1 )',
-	'( const char ** strings, int numStrings = -1, int index = -1 )',
-	'( const QStringList & list, int index = -1 )',
-	'( int index = 0 )',
-	'( bool ascending = true )',
-	'( Q3ListBox * listbox = 0 )',
-	'( Q3ListBox * listbox, const QString & text = QString())',
-	'( const QString & text = QString())',
-	'( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )',
-	'( const QString & label, int width = -1 )',
-	'( const QIcon & icon, const QString & label, int width = -1 )',
-	'( const QString & text, int column, ComparisonFlags compare = ExactMatch | Qt::CaseSensitive )',
-	'( int column, bool ascending = true )',
-	'( Q3ListView * parent, const QString & label1, const QString & label2 = QString())',
-	'( Q3ListViewItem * parent, const QString & label1, const QString & label2 = QString())',
-	'( Q3ListView * parent, Q3ListViewItem * after, const QString & label1, const QString & label2 = QString())',
-	'( Q3ListViewItem * parent, Q3ListViewItem * after, const QString & label1, const QString & label2 = QString())',
-	'( int c = -1 )',
-	'( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = Qt::WType_TopLevel )',
-	'( Q3DockWindow * dockWindow, Qt::Dock edge = Qt::DockTop, bool newLine = false )',
-	'( Q3DockWindow * dockWindow, const QString & label, Qt::Dock edge = Qt::DockTop, bool newLine = false )',
-	'( Q3DockWindow * dockWindow, Qt::Dock position = Qt::DockTop, bool newLine = false )',
-	'( Q3DockWindow * dockWindow, const QString & label, Qt::Dock position = Qt::DockTop, bool newLine = false )',
-	'( DockWindows dockWindows = AllDockWindows )',
-	'( bool keepNewLines = false )',
-	'( bool keepNewLines = false )',
-	'( int pos, int length = -1 )',
-	'( const QSize & size, QVideoFrame::PixelFormat format, QAbstractVideoBuffer::HandleType type = QAbstractVideoBuffer::NoHandle )',
-	'( QMutex * mutex, unsigned long time = ULONG_MAX )',
-	'( QReadWriteLock * readWriteLock, unsigned long time = ULONG_MAX )',
-	'( const QString & name, const QString & defaultValue = QString())',
-	'( const QString & namespaceUri, const QString & name, const QString & defaultValue = QString())',
-	'( const QString & namespaceUri = QString())',
-	'( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion())',
-	'( const QByteArray & data, const QString & mimeType = QString())',
-	'( const QString & html, const QUrl & baseUrl = QUrl())',
-	'( QObject * parent = 0 )',
-	'( QWidget * parent = 0 )',
-	'( QObject * parent = 0 )',
-	'( Extension extension, const ExtensionOption * option = 0, ExtensionReturn * output = 0 )',
-	'( const QString & subString, FindFlags options = 0 )',
-	'( WebAction action, bool checked = false )',
-	'( QObject * parent = 0 )',
-	'(Volume< VoxelType > &volData, const Region &regionToSmooth)',
-	'(const VolumeSampler< VoxelType > &volIter)',
-	'(VolumeSampler< VoxelType > &volIter)',
-	'(VolumeSampler< VoxelType > &volIter)',
-	'(const VolumeSampler< VoxelType > &volIter)',
-	'(VolumeSampler< VoxelType > &volIter)',
-	'(Volume< uint8_t > *volumeData, SurfaceMesh &mesh, NormalGenerationMethod normalGenerationMethod)',
-	'(Volume< uint8_t > *volumeData, const Vector3DFloat &v3dPos, NormalGenerationMethod normalGenerationMethod)',
-	'(const VolumeSampler< VoxelType > &volIter)',
-	'(const MeshEdge &lhs, const MeshEdge &rhs)',
-	'(const MeshEdge &lhs, const MeshEdge &rhs)',
-	'(const Vector< Size, Type > &lhs, const Vector< Size, Type > &rhs)',
-	'(const Vector< Size, Type > &lhs, const Vector< Size, Type > &rhs)',
-	'(const Vector< Size, Type > &lhs, const Type &rhs)',
-	'(const Vector< Size, Type > &lhs, const Type &rhs)',
-	'(std::ostream &os, const Vector< Size, Type > &vector)',
-	'(VolumeSampler< uint8_t > &volIter)',
-	'(const SurfaceEdge &lhs, const SurfaceEdge &rhs)',
-	'(const SurfaceEdge &lhs, const SurfaceEdge &rhs)',
-	'(std::istream &stream, VolumeSerializationProgressListener *progressListener=0)',
-	'(std::ostream &stream, Volume< VoxelType > &volume, VolumeSerializationProgressListener *progressListener=0)',
-	'(std::istream &stream, VolumeSerializationProgressListener *progressListener=0)',
-	'(std::ostream &stream, Volume< VoxelType > &volume, VolumeSerializationProgressListener *progressListener=0)',
-	'(const uint32_t(&pDimensions)[noOfDims])',
-	'(uint32_t uIndex)',
-	'(uint32_t uIndex) const ',
-	'(void) const', 
-	'(void) const', 
-	'(const uint32_t(&pDimensions)[noOfDims])',
-	'(Array< noOfDims, ElementType > &rhs)',
-	'( const QString & path, const QString & nameFilter, SortFlags sort = SortFlags( Name | IgnoreCase ))',
-	'( const QBrush & foreground, const QBrush & button, const QBrush & light, const QBrush & dark, const QBrush & mid, const QBrush & text, const QBrush & bright_text, const QBrush & base, const QBrush & background )',
-	'( int width, int height, Attachment attachment, GLenum target = GL_TEXTURE_2D, GLenum internal_format = GL_RGBA8 )',
-	'( GLuint texture_id )',
-	'PolyVox::Volume::getDepth',
-	'PolyVox::Volume::getDepth()',
-	'Volume::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tDefault=VoxelType()) const',
-	'PolyVox::Array::operator[]',
-	'operator[]',
-	'( Q3ValueList<T>::size_type i )',
-	]
-	
-	for sample in samples:
-		print sample
-		normalised_sample = normalise(sample)
-		print normalised_sample, '\n'

doxylink/test/__init__.py

Empty file added.

doxylink/test/test_parser.py

+import unittest
+
+from sphinxcontrib import parsing
+
+class TestNormalise(unittest.TestCase):
+	def setUp(self):
+		self.arglists = [('( QUrl source )', ('', '(QUrl)')),
+		                 ('( QUrl * source )', ('', '(QUrl*)')),
+		                 ('( QUrl ** source )', ('', '(QUrl**)')),
+		                 ('( const QUrl ** source )', ('', '(const QUrl**)')),
+		                 ('( const QUrl source )', ('', '(const QUrl)')),
+		                 ('( QUrl & source )', ('', '(QUrl&)')),
+		                 ('( const QUrl & source )', ('', '(const QUrl&)')),
+		                 ('( const QUrl * source )', ('', '(const QUrl*)')),
+		                 ('( const QByteArray & data, const QUrl & documentUri = QUrl() )', ('', '(const QByteArray&, const QUrl&)')),
+		                 ('(void)', ('', '(void)')),
+		                 ('(uint32_t uNoOfBlocksToProcess=(std::numeric_limits< uint32_t >::max)())', ('', '(uint32_t)')),
+		                 ('( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )', ('', '(QWidget*, const char*, Qt::WindowFlags)')),
+		                 ('()', ('', '()')),
+		                 ('( const QPixmap & pixmap, const QString & text, int index = -1 )', ('', '(const QPixmap&, const QString&, int)')),
+		                 ('( const char ** strings, int numStrings = -1, int index = -1 )', ('', '(const char**, int, int)')),
+		                 ('( const QStringList & list, int index = -1 )', ('', '(const QStringList&, int)')),
+		                 ('( int index = 0 )', ('', '(int)')),
+		                 ('( bool ascending = true )', ('', '(bool)')),
+		                 ('( const QIcon & icon, const QString & label, int width = -1 )', ('', '(const QIcon&, const QString&, int)')),
+		                 ('( const QString & text, int column, ComparisonFlags compare = ExactMatch | Qt::CaseSensitive )', ('', '(const QString&, int, ComparisonFlags)')),
+		                 ('( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = Qt::WType_TopLevel )', ('', '(QWidget*, const char*, Qt::WindowFlags)')),
+		                 ('( QMutex * mutex, unsigned long time = ULONG_MAX )', ('', '(QMutex*, unsigned long)')),
+		                 ('( QReadWriteLock * readWriteLock, unsigned long time = ULONG_MAX )', ('', '(QReadWriteLock*, unsigned long)')),
+		                 ('(const VolumeSampler< VoxelType > &volIter)', ('', '(const VolumeSampler< VoxelType >&)')),
+		                 ('(VolumeSampler< VoxelType > &volIter)', ('', '(VolumeSampler< VoxelType >&)')),
+		                 ('(const VolumeSampler< VoxelType > &volIter)', ('', '(const VolumeSampler< VoxelType >&)')),
+		                 ('(const uint32_t(&pDimensions)[noOfDims])', ('', '(const uint32_t)')),
+		                 ('(Array< noOfDims, ElementType > &rhs)', ('', '(Array< noOfDims, ElementType >&)')),
+		                 ('( const QString & path, const QString & nameFilter, SortFlags sort = SortFlags( Name | IgnoreCase ))', ('', '(const QString&, const QString&, SortFlags)')),
+		                 ('( GLuint texture_id )', ('', '(GLuint)')),
+		                 ('( Q3ValueList<T>::size_type i )', ('', '(Q3ValueList<T>::size_type)')),
+		]
+		
+		self.functions = [('PolyVox::Volume::getDepth', ('PolyVox::Volume::getDepth', '')),
+		                  ('PolyVox::Volume::getDepth()', ('PolyVox::Volume::getDepth', '()')),
+		                  ('Volume::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tDefault=VoxelType()) const', ('Volume::getVoxelAt', '(uint16_t, uint16_t, uint16_t, VoxelType) const')),
+		                  ('PolyVox::Array::operator[]', ('PolyVox::Array::operator[]', '')),
+		                  ('operator[]', ('operator[]', '')),
+		]
+	
+	def test_split_function(self):
+		for function in self.functions:
+			self.assertEqual(parsing.normalise(function[0]), function[1])
+			
+	def test_normalise_arglist(self):
+		for arglist in self.arglists:
+			self.assertEqual(parsing.normalise(arglist[0]), arglist[1])
+
+if __name__ == '__main__':
+    unittest.main()
+
 [testenv:python]
 deps=
     py
+	nose
 commands=
-    py.test
+    nosetests
 
 [testenv:doc]
 deps=