| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,7 @@ | |||
| 1 | + sources: | ||
| 2 | + - glob: new-tutorials/* | ||
| 3 | + reason: new tutorial staging | ||
| 4 | + urls: | ||
| 1 | 5 | - url: plugin_discovery.html#plugin-creation-and-discovery | |
| 2 | 6 | reason: named link to first header | |
| 3 | 7 | - url: single_source_version.html#single-sourcing-the-project-version | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | # http://creativecommons.org/licenses/by-sa/3.0. | |
| 5 | 5 | ||
| 6 | 6 | import argparse | |
| 7 | + from fnmatch import fnmatch | ||
| 7 | 8 | from glob import glob | |
| 8 | 9 | import io | |
| 9 | 10 | import os | |
@@ -18,9 +19,9 @@ | |||
| 18 | 19 | IGNORED_FILENAME = os.path.join(HERE, 'ignored.yaml') | |
| 19 | 20 | ROOT = os.path.abspath(os.path.join(HERE, '..', '..')) | |
| 20 | 21 | HTML_DIR = os.path.join(ROOT, 'build', 'html') | |
| 21 | - IGNORED_FILES = [ | ||
| 22 | + IGNORED_FILES = set([ | ||
| 22 | 23 | 'genindex.html' | |
| 23 | - ] | ||
| 24 | + ]) | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | 27 | def find_all_named_anchors(filename): | |
@@ -61,9 +62,13 @@ def find_all_named_anchors_in_files(files): | |||
| 61 | 62 | return links | |
| 62 | 63 | ||
| 63 | 64 | ||
| 64 | - def find_links(): | ||
| 65 | + def find_links(ignored_files): | ||
| 65 | 66 | files = glob('**/*.html', recursive=True) | |
| 66 | - files = filter(lambda name: name not in IGNORED_FILES, files) | ||
| 67 | + ignored_files = ignored_files | IGNORED_FILES | ||
| 68 | + files = [ | ||
| 69 | + filename for filename in files | ||
| 70 | + if not any( | ||
| 71 | + [fnmatch(filename, pattern) for pattern in ignored_files])] | ||
| 67 | 72 | return find_all_named_anchors_in_files(files) | |
| 68 | 73 | ||
| 69 | 74 | ||
@@ -87,7 +92,9 @@ def load_redirects(): | |||
| 87 | 92 | def load_ignored(): | |
| 88 | 93 | with io.open(IGNORED_FILENAME, 'r') as ignored_file: | |
| 89 | 94 | raw = yaml.load(ignored_file) | |
| 90 | - return set([entry['url'] for entry in raw]) | ||
| 95 | + sources = set([entry['glob'] for entry in raw['sources']]) | ||
| 96 | + urls = set([entry['url'] for entry in raw['urls']]) | ||
| 97 | + return sources, urls | ||
| 91 | 98 | ||
| 92 | 99 | ||
| 93 | 100 | def expand_redirects(redirects, inventory, ignored): | |
@@ -152,11 +159,11 @@ def check_command(args): | |||
| 152 | 159 | # TODO: Add another file to list currently defined redirects. | |
| 153 | 160 | inventory = load_inventory() | |
| 154 | 161 | redirects = load_redirects() | |
| 155 | - ignored = load_ignored() | ||
| 156 | - links = find_links() | ||
| 162 | + ignored_sources, ignored_urls = load_ignored() | ||
| 163 | + links = find_links(ignored_sources) | ||
| 157 | 164 | ||
| 158 | 165 | valid_redirects, missing_redirects = expand_redirects( | |
| 159 | - redirects, inventory, ignored) | ||
| 166 | + redirects, inventory, ignored_urls) | ||
| 160 | 167 | if missing_redirects: | |
| 161 | 168 | print( | |
| 162 | 169 | 'The following redirects are missing deep link anchors in the ' | |
@@ -169,7 +176,7 @@ def check_command(args): | |||
| 169 | 176 | ||
| 170 | 177 | ignored_links = set() | |
| 171 | 178 | for link in missing_links: | |
| 172 | - for source_url in ignored: | ||
| 179 | + for source_url in ignored_urls: | ||
| 173 | 180 | if link.startswith(source_url): | |
| 174 | 181 | ignored_links.add(link) | |
| 175 | 182 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + :orphan: | ||
| 2 | + | ||
| 3 | + New Tutorials | ||
| 4 | + ============= | ||
| 5 | + | ||
| 6 | + .. warning:: This section is for work-in-progress tutorials! These will | ||
| 7 | + eventually be promoted to the :doc:`/tutorials/index` section. | ||
| 8 | + Do not link to these pages! | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments