From 61e20786a975f0555829635fcfb591794cc8cdef Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 21 Mar 2017 17:13:06 -0400 Subject: [PATCH] docs: fix links in generated docs (#4200) --- build/fix-api-docs.js | 20 +++++++++++++++ docs/guides/audio-tracks.md | 10 +++++--- docs/guides/components.md | 6 +++-- docs/guides/debugging.md | 2 +- docs/guides/faq.md | 21 ++++++++++------ docs/guides/languages.md | 14 +++++------ docs/guides/modal-dialog.md | 6 ++--- docs/guides/options.md | 16 +++++++----- docs/guides/player-workflows.md | 8 +++--- docs/guides/plugins.md | 12 ++++++--- docs/guides/react.md | 5 ++-- docs/guides/setup.md | 8 +++--- docs/guides/text-tracks.md | 4 +-- docs/guides/tracks.md | 6 ++--- docs/guides/troubleshooting.md | 2 +- docs/guides/video-tracks.md | 4 +-- docs/guides/videojs.md | 2 +- docs/index.md | 32 ++++++++++++------------ docs/translations-needed.md | 3 +++ package.json | 7 ++++-- src/js/player.js | 10 ++++---- src/js/setup.js | 2 +- src/js/tech/tech.js | 4 +-- src/js/tracks/html-track-element-list.js | 2 +- src/js/tracks/track-types.js | 4 +-- src/js/utils/dom.js | 4 +-- src/js/video.js | 4 +-- 27 files changed, 132 insertions(+), 86 deletions(-) create mode 100644 build/fix-api-docs.js diff --git a/build/fix-api-docs.js b/build/fix-api-docs.js new file mode 100644 index 0000000000..bf8a37a919 --- /dev/null +++ b/build/fix-api-docs.js @@ -0,0 +1,20 @@ +var replace = require("replace"); +var path = require('path') +var apiPath = path.join(__dirname, '..', 'docs', 'api'); + +var replacements = [ + {find: /\/docs\/guides\/(.+)\.md/g, replace: 'tutorial-$1.html'}, + {find: /tutorial-tech.html/g, replace: 'tutorial-tech_.html'}, + {find: /\/docs\/guides\//g, replace: '#'} +]; + + +replacements.forEach(function(obj) { + replace({ + regex: obj.find, + replacement: obj.replace, + paths: [apiPath], + recursive: true, + silent: true + }); +}); diff --git a/docs/guides/audio-tracks.md b/docs/guides/audio-tracks.md index b43d44fc60..c6f6c9ba7c 100644 --- a/docs/guides/audio-tracks.md +++ b/docs/guides/audio-tracks.md @@ -25,7 +25,7 @@ cross-browser implementation of audio tracks. They must be added programmatically. * Video.js only stores track representations. Switching audio tracks for playback is _not handled by Video.js_ and must be handled elsewhere - for example, - [videojs-contrib-hls](http://github.com/videojs/videojs-contrib-hls) handles switching + [videojs-contrib-hls][hls] handles switching audio tracks to support track selection through the UI. ## Working with Audio Tracks @@ -91,7 +91,7 @@ player.audioTracks().removeTrack(track); ## API For more complete information, refer to the -[Video.js API docs](http://docs.videojs.com/docs/api/index.html), specifically: +[Video.js API docs](http://docs.videojs.com/), specifically: * `Player#audioTracks` * `AudioTrackList` @@ -140,7 +140,7 @@ The valid [BCP 47](https://tools.ietf.org/html/bcp47) code for the language of t track, e.g. `"en"` for English or `"es"` for Spanish. For supported language translations, please see the [languages folder (/lang)](https://github.com/videojs/video.js/tree/master/lang) -located in the Video.js root and refer to the [languages guide](languages.md) for more +located in the Video.js root and refer to the [languages guide][languages-guide] for more information on languages in Video.js. #### `enabled` @@ -154,4 +154,8 @@ than one, the last one to be enabled will end up being the only one. While the s allows for more than one track to be enabled, Safari and most implementations only allow one audio track to be enabled at a time. +[languages-guide]: /docs/guides/languages.md + [spec-audiotrack]: https://html.spec.whatwg.org/multipage/embedded-content.html#audiotrack + +[hls]: http://github.com/videojs/videojs-contrib-hls diff --git a/docs/guides/components.md b/docs/guides/components.md index 214d89f128..f56025f9a1 100644 --- a/docs/guides/components.md +++ b/docs/guides/components.md @@ -29,7 +29,7 @@ A component is a JavaScript object that has the following features: * The ability to listen for and trigger events. * A lifecycle of initialization and disposal. -For more specifics on the programmatic interface of a component, see [the component API docs](http://docs.videojs.com/docs/api/component.html). +For more specifics on the programmatic interface of a component, see [the component API docs][api]. ## Creating a Component @@ -75,7 +75,7 @@ console.log(button.el()); ## Component Children -Again, refer to [the component API docs](http://docs.videojs.com/docs/api/component.html) for complete details on methods available for managing component structures. +Again, refer to [the component API docs][api] for complete details on methods available for managing component structures. ### Basic Example @@ -336,3 +336,5 @@ let player = videojs('myplayer', { ### Text Track Settings The text track settings component is only available when using emulated text tracks. + +[api]: http://docs.videojs.com/Component.html diff --git a/docs/guides/debugging.md b/docs/guides/debugging.md index d3206a0c8f..8a3940056a 100644 --- a/docs/guides/debugging.md +++ b/docs/guides/debugging.md @@ -107,6 +107,6 @@ Finally, the history (if enabled) can be cleared at any time via: videojs.log.history.clear(); ``` -[api]: http://docs.videojs.com/docs/api/index.html +[api]: http://docs.videojs.com/ [console]: https://developer.mozilla.org/en-US/docs/Web/API/Console diff --git a/docs/guides/faq.md b/docs/guides/faq.md index 428a47f96a..eabebb6588 100644 --- a/docs/guides/faq.md +++ b/docs/guides/faq.md @@ -112,7 +112,7 @@ with your issue. A reduced test case is an example of the problem that you are facing in isolation. Think of it as example page that reproduces the issue in the least amount of possible code. We have a [starter example][starter-example] for reduced test cases. To learn more -about reduced test cases visit [css-tricks](https://css-tricks.com/reduced-test-cases/) +about reduced test cases visit [css-tricks][reduced-test-case] ## Q: What media formats does video.js support? @@ -270,19 +270,25 @@ Be sure to use `require('!style-loader!css-loader!video.js/dist/video-js.css')` ## Q: Does video.js work with react? -Yes! See [ReactJS integration example](./guides/react.md). +Yes! See [ReactJS integration example][react-guide]. -[plugin-guide]: plugins.md +[reduced-test-case]: https://css-tricks.com/reduced-test-cases/ + +[react-guide]: /docs/guides/react.md + +[plugin-guide]: /docs/guides/plugins.md [install-guide]: http://videojs.com/getting-started/ -[troubleshooting]: troubleshooting.md +[troubleshooting]: /docs/guides/troubleshooting.md + +[video-tracks]: /docs/guides/video-tracks.md -[video-tracks]: video-tracks.md +[audio-tracks]: /docs/guides/audio-tracks.md -[audio-tracks]: audio-tracks.md +[text-tracks]: /docs/guides/text-tracks.md -[text-tracks]: text-tracks.md +[debug-guide]: /docs/guides/debugging.md [pr-issue-question]: #q-i-think-i-found-a-bug-with-videojs-or-i-want-to-add-a-feature-what-should-i-do @@ -324,4 +330,3 @@ Yes! See [ReactJS integration example](./guides/react.md). [starter-example]: http://jsbin.com/axedog/edit?html,output -[debug-guide]: ./guides/debug.md diff --git a/docs/guides/languages.md b/docs/guides/languages.md index 0e1c03b091..eef59df751 100644 --- a/docs/guides/languages.md +++ b/docs/guides/languages.md @@ -58,12 +58,12 @@ Finally, each file's extension is always `.json`. ### Updating an Existing Translation -If there is a [missing translation](../translations-needed.md), mistake, or room for improvement in an existing translation, don't hesitate to open a pull request! +If there is a [missing translation](/docs/translations-needed.md), mistake, or room for improvement in an existing translation, don't hesitate to open a pull request! 1. Edit the relevant JSON file and make the necessary changes. 1. Verify the language compiles by running `grunt dist`. 1. Verify the translation appears properly in the player UI. -1. Run `grunt check-translations` to update the [missing translation document](../translations-needed.md). +1. Run `grunt check-translations` to update the [missing translation document](/docs/translations-needed.md). 1. Commit and open a pull request on GitHub. ### Writing a New Translation @@ -103,7 +103,7 @@ videojs.addLanguage('es', { ### Per-Player Languages -In addition to providing languages to Video.js itself, individual `Player` instances can be provided custom language support via [the `languages` option](options.md#languages): +In addition to providing languages to Video.js itself, individual `Player` instances can be provided custom language support via [the `languages` option](/docs/guides/options.md#languages): ```js // Provide a custom definition of Spanish to this player. @@ -116,7 +116,7 @@ videojs('my-player', { ### Setting Default Player Language -Player instances can also have a default language via [the `language` option](options.md#language): +Player instances can also have a default language via [the `language` option](/docs/guides/options.md#language): ```js // Set the default language to Spanish for this player. @@ -143,14 +143,14 @@ The player language is set to one of the following in descending priority: ## References -For information on translation/localization in plugins, see [the plugins guide](plugins.md). +For information on translation/localization in plugins, see [the plugins guide](/docs/guides/plugins.md). Standard languages codes [are defined by the IANA][lang-codes]. For all existing/supported languages, please see the [languages lolder (`lang/`)][lang-supported] folder located in the project root. -[lang-en]: https://github.com/videojs/video.js/tree/master/lang/en.json +[lang-en]: /lang/en.json -[lang-supported]: https://github.com/videojs/video.js/tree/master/lang +[lang-supported]: /lang [lang-codes]: http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry diff --git a/docs/guides/modal-dialog.md b/docs/guides/modal-dialog.md index bf4f91fcc4..b8198f96fc 100644 --- a/docs/guides/modal-dialog.md +++ b/docs/guides/modal-dialog.md @@ -4,7 +4,7 @@ The `ModalDialog` component is part of Video.js core and provides a baked-in UI ## Table of Contents -* [Creating the ModalDialog](#creating-the-modaldialog) +* [Creating a ModalDialog](#creating-a-modaldialog) * [Example Using createModal()](#example-using-createmodal) * [Example Using the ModalDialog Constructor](#example-using-the-modaldialog-constructor) * [Styling Modals Independently](#styling-modals-independently) @@ -73,6 +73,6 @@ A common need for modals is to style them independently from one another. The re modal.addClass('vjs-my-fancy-modal'); ``` -[api-doc]: http://docs.videojs.com/docs/api/modal-dialog.html +[api-doc]: http://docs.videojs.com/ModalDialog.html -[creating-component]: ./components.md#creating-a-component +[creating-component]: /docs/guides/components.md#creating-a-component diff --git a/docs/guides/options.md b/docs/guides/options.md index f5150600ac..ebe55e2dd9 100644 --- a/docs/guides/options.md +++ b/docs/guides/options.md @@ -1,6 +1,6 @@ # Video.js Options Reference -> **Note:** This document is only a reference for available options. To learn about passing options to Video.js, see [the setup guide](setup.md#options). +> **Note:** This document is only a reference for available options. To learn about passing options to Video.js, see [the setup guide](/docs/guides/setup.md#options). ## Table of Contents @@ -41,7 +41,7 @@ ## Standard `