Pepijn de Vos avatar Pepijn de Vos committed ce2f619

add suggested edits and test

Comments (0)

Files changed (3)


     from ctags import CTags, TagEntry
 except ImportError:
-    pass
+    CTags = None
 __all__ = ['HtmlFormatter']
         self.urlformat = self._decodeifneeded(options.get('urlformat', ''))
         if self.tagsfile:
-            try:
+            if CTags:
                 self.ct = CTags(self.tagsfile)
-            except NameError:
-                print >> sys.stderr, 'Hey! ctags doesn\'t seem to be installed. Try \'pip install python-ctags\'.'
+            else:
+                raise NameError('Hey! ctags doesn\'t seem to be installed. Try \'pip install python-ctags\'.')
         linenos = options.get('linenos', False)
         if linenos == 'inline':


+!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
+!_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
+!_TAG_PROGRAM_AUTHOR	Darren Hiebert	/
+!_TAG_PROGRAM_NAME	Exuberant Ctags	//
+!_TAG_PROGRAM_URL	/official site/
+HtmlFormatter	19;"	i
+HtmlFormatterTest	34;"	c
+NullFormatter	19;"	i
+PythonLexer	18;"	i
+StringIO	13;"	i
+dirname	16;"	i
+escape_html	20;"	i
+fp	27;"	v
+inspect	15;"	i
+isfile	16;"	i
+join	16;"	i
+os	10;"	i
+re	11;"	i
+subprocess	125;"	i
+support	23;"	i
+tempfile	14;"	i
+test_all_options	72;"	m	class:HtmlFormatterTest
+test_correct_output	35;"	m	class:HtmlFormatterTest
+test_ctags	165;"	m	class:HtmlFormatterTest
+test_external_css	48;"	m	class:HtmlFormatterTest
+test_get_style_defs	141;"	m	class:HtmlFormatterTest
+test_lineanchors	98;"	m	class:HtmlFormatterTest
+test_lineanchors_with_startnum	106;"	m	class:HtmlFormatterTest
+test_linenos	82;"	m	class:HtmlFormatterTest
+test_linenos_with_startnum	90;"	m	class:HtmlFormatterTest
+test_unicode_options	155;"	m	class:HtmlFormatterTest
+test_valid_output	114;"	m	class:HtmlFormatterTest
+tokensource	29;"	v
+uni_open	21;"	i
+unittest	12;"	i


         tfile = os.fdopen(handle, 'w+b')
         fmt.format(tokensource, tfile)
+    def test_ctags(self): # make sure this is in fact line 165 and the tags file says so
+        fmt = HtmlFormatter(tagsfile='examplefiles/tags', lineanchors="L")
+        outfile = StringIO.StringIO()
+        fmt.format(tokensource, outfile)
+        self.assertTrue('<a href="#L-165">test_ctags</a>' in outfile.getvalue())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.