Browse Source

docs: improve relative link linting and fix broken (#26020)

David Sanders 4 years ago
parent
commit
e6f570d191

+ 1 - 1
docs/api/command-line-switches.md

@@ -232,7 +232,7 @@ Specify ways of the inspector web socket url exposure.
 By default inspector websocket url is available in stderr and under /json/list endpoint on http://host:port/json/list.
 
 [app]: app.md
-[append-switch]: app.md#appcommandlineappendswitchswitch-value
+[append-switch]: command-line.md#commandlineappendswitchswitch-value
 [ready]: app.md#event-ready
 [play-silent-audio]: https://github.com/atom/atom/pull/9485/files
 [debugging-main-process]: ../tutorial/debugging-main-process.md

+ 1 - 1
docs/api/desktop-capturer.md

@@ -95,7 +95,7 @@ Returns `Promise<DesktopCapturerSource[]>` - Resolves with an array of [`Desktop
 which can detected by [`systemPreferences.getMediaAccessStatus`].
 
 [`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
-[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-macos
+[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos
 
 ## Caveats
 

+ 1 - 1
docs/api/structures/ipc-renderer-event.md

@@ -4,4 +4,4 @@
 * `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
 * `ports` MessagePort[] - A list of MessagePorts that were transferred with this message
 
-[ipc-renderer-sendto]: #ipcrenderersendtowindowid-channel--arg1-arg2-
+[ipc-renderer-sendto]: ../ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args

+ 1 - 1
docs/tutorial/progress-bar.md

@@ -32,4 +32,4 @@ win.setProgressBar(0.5)
 ```
 
 [taskbar-progress-image]: https://cloud.githubusercontent.com/assets/639601/5081682/16691fda-6f0e-11e4-9676-49b6418f1264.png
-[setprogressbar]: ../api/browser-window.md#winsetprogressbarprogress
+[setprogressbar]: ../api/browser-window.md#winsetprogressbarprogress-options

+ 1 - 1
docs/tutorial/security.md

@@ -814,6 +814,6 @@ which potential security issues are not as widely known.
 [web-contents]: ../api/web-contents.md
 [new-window]: ../api/web-contents.md#event-new-window
 [will-navigate]: ../api/web-contents.md#event-will-navigate
-[open-external]: ../api/shell.md#shellopenexternalurl-options-callback
+[open-external]: ../api/shell.md#shellopenexternalurl-options
 [sandbox]: ../api/sandbox-option.md
 [responsible-disclosure]: https://en.wikipedia.org/wiki/Responsible_disclosure

+ 9 - 3
script/check-relative-doc-links.py

@@ -48,14 +48,20 @@ def getBrokenLinks(filepath):
   finally:
     f.close()
 
-  regexLink = re.compile('\[(.*?)\]\((?P<links>(.*?))\)')
+  linkRegexLink = re.compile('\[(.*?)\]\((?P<link>(.*?))\)')
+  referenceLinkRegex = re.compile('^\s{0,3}\[.*?\]:\s*(?P<link>[^<\s]+|<[^<>\r\n]+>)')
   links = []
   for line in lines:
-    matchLinks = regexLink.search(line)
+    matchLinks = linkRegexLink.search(line)
+    matchReferenceLinks = referenceLinkRegex.search(line)
     if matchLinks:
-      relativeLink = matchLinks.group('links')
+      relativeLink = matchLinks.group('link')
       if not str(relativeLink).startswith('http'):
         links.append(relativeLink)
+    if matchReferenceLinks:
+      referenceLink = matchReferenceLinks.group('link').strip('<>')
+      if not str(referenceLink).startswith('http'):
+        links.append(referenceLink)
 
   for link in links:
     sections = link.split('#')