2016-10-03 18:19:13 +00:00
|
|
|
|
//- 💫 INCLUDES > FUNCTIONS
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
2017-10-03 12:20:13 +00:00
|
|
|
|
//- Descriptive variables, available in the global scope
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
|
|
|
|
- CURRENT = current.source
|
|
|
|
|
- SECTION = current.path[0]
|
2017-10-03 12:20:13 +00:00
|
|
|
|
- LANGUAGES = public.models._data.LANGUAGES
|
|
|
|
|
- MODELS = public.models._data.MODELS
|
|
|
|
|
- CURRENT_MODELS = MODELS[current.source] || []
|
|
|
|
|
|
|
|
|
|
- MODEL_COUNT = Object.keys(MODELS).map(m => Object.keys(MODELS[m]).length).reduce((a, b) => a + b)
|
|
|
|
|
- MODEL_LANG_COUNT = Object.keys(MODELS).length
|
|
|
|
|
- LANG_COUNT = Object.keys(LANGUAGES).length
|
|
|
|
|
|
|
|
|
|
- MODEL_META = public.models._data.MODEL_META
|
|
|
|
|
- MODEL_LICENSES = public.models._data.MODEL_LICENSES
|
2017-10-29 02:58:19 +00:00
|
|
|
|
- MODEL_BENCHMARKS = public.models._data.MODEL_BENCHMARKS
|
2018-04-29 00:06:46 +00:00
|
|
|
|
- EXAMPLE_SENT_LANGS = public.models._data.EXAMPLE_SENT_LANGS
|
2017-10-03 12:20:13 +00:00
|
|
|
|
- EXAMPLE_SENTENCES = public.models._data.EXAMPLE_SENTENCES
|
|
|
|
|
|
|
|
|
|
- IS_PAGE = (SECTION != "index") && !landing
|
|
|
|
|
- IS_MODELS = (SECTION == "models" && LANGUAGES[current.source])
|
|
|
|
|
- HAS_MODELS = IS_MODELS && CURRENT_MODELS.length
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
2018-04-29 00:06:46 +00:00
|
|
|
|
//- Get page URL
|
|
|
|
|
|
|
|
|
|
- function getPageUrl() {
|
|
|
|
|
- var path = current.path;
|
|
|
|
|
- if(path[path.length - 1] == 'index') path = path.slice(0, path.length - 1);
|
|
|
|
|
- return `${SITE_URL}/${path.join('/')}`;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
//- Get pretty page title depending on section
|
|
|
|
|
|
|
|
|
|
- function getPageTitle() {
|
|
|
|
|
- var sections = ['api', 'usage', 'models'];
|
|
|
|
|
- if (sections.includes(SECTION)) {
|
|
|
|
|
- var titleSection = (SECTION == "api") ? 'API' : SECTION.charAt(0).toUpperCase() + SECTION.slice(1);
|
|
|
|
|
- return `${title} · ${SITENAME} ${titleSection} Documentation`;
|
|
|
|
|
- }
|
|
|
|
|
- else if (SECTION != 'index') return `${title} · ${SITENAME}`;
|
|
|
|
|
- return `${SITENAME} · ${SLOGAN}`;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
//- Get social image based on section and settings
|
|
|
|
|
|
|
|
|
|
- function getPageImage() {
|
|
|
|
|
- var img = (SECTION == 'api') ? 'api' : 'default';
|
|
|
|
|
- return `${SITE_URL}/assets/img/social/preview_${preview || img}.jpg`;
|
|
|
|
|
- }
|
2016-03-31 14:24:48 +00:00
|
|
|
|
|
2016-10-03 18:19:13 +00:00
|
|
|
|
//- Add prefixes to items of an array (for modifier CSS classes)
|
2017-10-03 12:20:13 +00:00
|
|
|
|
array - [array] list of class names or options, e.g. ["foot"]
|
|
|
|
|
prefix - [string] prefix to add to each class, e.g. "c-table__row"
|
|
|
|
|
RETURNS - [array] list of modified class names
|
2016-03-31 14:24:48 +00:00
|
|
|
|
|
|
|
|
|
- function prefixArgs(array, prefix) {
|
2017-10-03 12:20:13 +00:00
|
|
|
|
- return array.map(arg => prefix + '--' + arg).join(' ');
|
2016-03-31 14:24:48 +00:00
|
|
|
|
- }
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-03 12:20:13 +00:00
|
|
|
|
//- Convert API paths (semi-temporary fix for renamed sections)
|
|
|
|
|
path - [string] link path supplied to +api mixin
|
|
|
|
|
RETURNS - [string] new link path to correct location
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
2017-10-03 12:20:13 +00:00
|
|
|
|
- function convertAPIPath(path) {
|
|
|
|
|
- if (path.startsWith('spacy#') || path.startsWith('displacy#') || path.startsWith('util#')) {
|
|
|
|
|
- var comps = path.split('#');
|
|
|
|
|
- return "top-level#" + comps[0] + '.' + comps[1];
|
|
|
|
|
- }
|
|
|
|
|
- return path;
|
2016-10-31 18:04:15 +00:00
|
|
|
|
- }
|
2017-06-01 12:27:44 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-03 12:20:13 +00:00
|
|
|
|
//- Get model components from ID. Components can then be looked up in LANGUAGES
|
|
|
|
|
and MODEL_META respectively, to get their human-readable form.
|
|
|
|
|
id - [string] model ID, e.g. "en_core_web_sm"
|
|
|
|
|
RETURNS - [object] object keyed by components lang, type, genre and size
|
2017-06-01 12:27:44 +00:00
|
|
|
|
|
2017-10-03 12:20:13 +00:00
|
|
|
|
- function getModelComponents(id) {
|
|
|
|
|
- var comps = id.split('_');
|
|
|
|
|
- return {'lang': comps[0], 'type': comps[1], 'genre': comps[2], 'size': comps[3]}
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//- Generate GitHub links
|
|
|
|
|
repo - [string] name of repo owned by explosion
|
|
|
|
|
filepath - [string] logical path to file relative to repository root
|
|
|
|
|
branch - [string] optional branch, defaults to "master"
|
|
|
|
|
RETURNS - [string] the correct link to the file on GitHub
|
|
|
|
|
|
|
|
|
|
- function gh(repo, filepath, branch) {
|
|
|
|
|
- var branch = ALPHA ? 'develop' : branch
|
|
|
|
|
- return 'https://github.com/' + SOCIAL.github + '/' + (repo || '') + (filepath ? '/blob/' + (branch || 'master') + '/' + filepath : '' );
|
2017-06-01 12:27:44 +00:00
|
|
|
|
- }
|