Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
Accelerator
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
apiaryio
/
dredd
Public archive
Notifications
You must be signed in to change notification settings
Fork
276
Star
4.2k
Code
Issues
211
Pull requests
49
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Files
Expand file tree
ba8771528cd2158861258de06d2ecc0c5ebb2c37
Breadcrumbs
dredd
/
docs
/
_extensions
/
ghlink_check.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
61 lines (42 loc) · 1.89 KB
ba87715
Breadcrumbs
dredd
/
docs
/
_extensions
/
ghlink_check.py
Copy path
Top
File metadata and controls
Code
Blame
61 lines (42 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import unittest
from pathlib import Path
from urllib.parse import urlparse
import docutils
from sphinx.util import logging
def check_uri(uri):
if 'github.com/apiaryio/dredd/blob/master' in uri:
path = Path(urlparse(uri).path
.replace('apiaryio/dredd/blob/master', '.').lstrip('/'))
return path.exists()
return True
def ghlink_check(app, doctree, docname):
uris = filter(None, (
reference.get('refuri') for reference
in doctree.traverse(docutils.nodes.reference)
))
logger = logging.getLogger(__name__)
for uri in uris:
if not check_uri(uri):
logger.error("Broken link in '%s': %s", docname, uri)
def setup(app):
app.connect('doctree-resolved', ghlink_check)
return {'version': '1.0', 'parallel_read_safe': True}
class Tests(unittest.TestCase):
def test_local(self):
self.assertTrue(check_uri('page.html#usage'))
def test_external(self):
self.assertTrue(check_uri('https://apiblueprint.org'))
def test_github(self):
self.assertTrue(check_uri('https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md'))
def test_relevant_github_repo_but_irrelevant_path(self):
self.assertTrue(check_uri('https://github.com/apiaryio/dredd/issues/820'))
def test_local_github_project_root_without_slash(self):
self.assertTrue(check_uri('https://github.com/apiaryio/dredd/blob/master'))
def test_local_github_project_root_with_slash(self):
self.assertTrue(check_uri('https://github.com/apiaryio/dredd/blob/master/'))
def test_local_github_existing(self):
self.assertTrue(check_uri('https://github.com/apiaryio/dredd/blob/master/README.md'))
def test_local_github_missing(self):
self.assertFalse(check_uri('https://github.com/apiaryio/dredd/blob/master/foo/bar/doesnt-exist'))
if __name__ == '__main__':
unittest.main()
You can’t perform that action at this time.