Matt Williams avatar Matt Williams committed 4746bc9

Only parse the tag file once per run.

Comments (0)

Files changed (2)

doxylink/CHANGES.rst

+0.3 (In Development)
+====================
+
+- Only parse the tag file once per run. This should increase the speed.
+
 0.2 (Jul 31, 2010)
 ====================
 

doxylink/sphinxcontrib/doxylink.py

 	if not rootdir.endswith(('/', '\\')):
 		rootdir = join(rootdir, os.sep)
 	
+	try:
+		tag_file = ET.parse(tag_filename)
+	except (IOError):
+		tag_file = None
+		app.warn('Could not open tag file %s. Make sure your `doxylink` config variable is set correctly.' % tag_filename)
+	
 	def find_doxygen_link(name, rawtext, text, lineno, inliner, options={}, content=[]):
 		text = utils.unescape(text)
 		# from :name:`title <part>`
 		has_explicit_title, title, part = split_explicit_title(text)
 		
-		try:
-			tag_file = ET.parse(tag_filename)
-		except (IOError):
-			env = inliner.document.settings.env
-			env.warn(env.docname, 'Could not open %s' % tag_filename)
-		else:
+		if tag_file:
 			url = find_url(tag_file, part)
 			if url:
 				
 			env = app.env
 			env.warn(env.docname, 'Could not find match for `%s` in `%s` tag file' % (part, tag_filename), lineno)
 		
+		
+		env = app.env
+		env.warn(env.docname, 'Could not find match for `%s` because tag file not found' % (part), lineno)
+		
 		pnode = nodes.inline(rawsource=title, text=title)
 		return [pnode], []
-		
+	
 	return find_doxygen_link
 
 def setup_doxylink_roles(app):
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 ProjectModifiedEvent.java.
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.