from urlparse import urlsplit
from file_system_util import CreateURLsFromPaths
-import svn_constants
+from path_util import AssertIsDirectory
+
Page = namedtuple('Page', 'status, links, anchors, anchor_refs')
+
def _SplitAnchor(url):
components = urlsplit(url)
return components.path, components.fragment
+
def _Process(path, renderer):
'''Render the page at |path| using a |renderer| and process the contents of
that page. Returns a |Page| namedtuple with fields for the http status code
return Page(200, edges, anchors, anchor_refs)
+
class _ContentParser(HTMLParser):
'''Parse an html file pulling out all links and anchor_refs, where an
anchor_ref is a link that contains an anchor.
if attrs.get('name'):
self.anchors.add(attrs['name'])
+
class LinkErrorDetector(object):
'''Finds link errors on the doc server. This includes broken links, those with
a target page that 404s or contain an anchor that doesn't exist, or pages that
template files. All URLs in |root_pages| are used as the starting nodes for
the orphaned page search.
'''
+ AssertIsDirectory(public_path)
self._file_system = file_system
self._renderer = renderer
self._public_path = public_path
processing the resultant html to pull out all links and anchors.
'''
top_level_directories = (
- (svn_constants.PUBLIC_TEMPLATE_PATH, ''),
- (svn_constants.STATIC_PATH, 'static/'),
- (svn_constants.EXAMPLES_PATH, 'extensions/examples/'),
+ ('docs/templates/public/', ''),
+ ('docs/static/', 'static/'),
+ ('docs/examples/', 'extensions/examples/'),
)
for dirpath, urlprefix in top_level_directories:
return [url for url in all_urls - found if url.endswith('.html')]
+
def StringifyBrokenLinks(broken_links):
'''Prints out broken links in a more readable format.
'''