Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4031)

Unified Diff: chrome/common/extensions/docs/server2/link_error_detector.py

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/link_error_detector.py
diff --git a/chrome/common/extensions/docs/server2/link_error_detector.py b/chrome/common/extensions/docs/server2/link_error_detector.py
index 459847092309f598b21b1208ab7d6af8c191f587..b495f319e9b37a0fce8404151bd15b570792f299 100644
--- a/chrome/common/extensions/docs/server2/link_error_detector.py
+++ b/chrome/common/extensions/docs/server2/link_error_detector.py
@@ -10,14 +10,16 @@ import posixpath
from urlparse import urlsplit
from file_system_util import CreateURLsFromPaths
-import svn_constants
+
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
@@ -78,6 +80,7 @@ def _Process(path, renderer):
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.
@@ -106,6 +109,7 @@ class _ContentParser(HTMLParser):
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
@@ -137,9 +141,9 @@ class LinkErrorDetector(object):
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:
@@ -269,6 +273,7 @@ class LinkErrorDetector(object):
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.
'''

Powered by Google App Engine
This is Rietveld 408576698