Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add build script for generating offline docsets #7642

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"build:toc": "yarn build:jekyll && scripts/generate-toc",
"build:site": "rollup -c site/rollup.config.js",
"build:jekyll": "pushd site && bundle exec jekyll build -q && popd",
"build:docset": "pushd site && bundle exec jekyll build -c _config_docset.yml -q && popd",
"build:versions": "scripts/update-version.sh",
"clean": "yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete",
"clean:build": "del-cli 'build/*' !build/vega-lite-schema.json",
Expand All @@ -53,6 +54,7 @@
"schema": "mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",
"renameschema": "scripts/rename-schema.sh",
"presite": "yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",
"docset": "yarn schema && yarn build:site && yarn build:docset && yarn build:versions && scripts/create-example-pages.sh",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skip the yarn data portion, since the docs can't read the served arrow/csv/json files via XMLHTTPRequest over the file system (which is how Dash serves them).

"site": "yarn site:only",
"site:only": "pushd site && bundle exec jekyll serve -I -l && popd",
"prettierbase": "prettier '**/*.{md,css,yml}'",
Expand Down
1 change: 1 addition & 0 deletions site/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exclude:
- Gemfile
- Gemfile.lock
- static/*.ts
is_docset_build: false # Control behaviors that make it easier to replace absolute with relative paths for offline friendly builds. False for deploying to the public docs.

markdown: kramdown
highlighter: none
Expand Down
35 changes: 35 additions & 0 deletions site/_config_docset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Config for building a docset
# For usage: https://github.com/hydrosquall/vega-lite-docset-generator

title: Vega-Lite
description: N/A

# Alternative: Rewrite the paths to relative URLs locally
# None of these worked when simply applied to base.html, so I ended up transforming
# the base URL in my python script instead. Leaving notes in here for posterity.
# https://ricostacruz.com/til/relative-paths-in-jekyll
# https://gist.github.com/Ketrel/1f36fca6b4148f7263b3ee8fdb0923e7
# https://github.com/jekyll/jekyll/issues/6360

baseurl: 'DOCSET_BASE_TO_REPLACE' # the subpath of your site, e.g. /blog/
url: 'https://vega.github.io' # the base hostname & protocol for your site
is_docset_build: true
twitter:
username: vega_vis
exclude:
- Gemfile
- Gemfile.lock
- static/*.ts

markdown: kramdown
highlighter: none

kramdown:
input: GFM
auto_id_stripping: true
syntax_highlighter_opts:
disable: true

plugins:
- jekyll-mentions
- jekyll-redirect-from
2 changes: 1 addition & 1 deletion site/_data/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vega: 5.20.2
vega-lite: 5.1.0
vega-embed: 6.18.2
vega-tooltip: 0.25.1
vega-tooltip: 0.27.0
9 changes: 7 additions & 2 deletions site/_layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@

<link rel="shortcut icon" href="https://vega.github.io/favicon.ico" />

{% seo %}

{% if site.is_docset_build == true %}
<script>
// Docset doesn't serve JSON from a fileserver, so it needs to load data from github
const BASEURL = 'https://vega.github.io/vega-lite/';
</script>
{% else %} {% seo %}
<script>
const BASEURL = window.location.origin + '{{site.baseurl}}';
</script>
{% endif %}

<link rel="stylesheet" href="{{ site.baseurl }}/static/github.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/octicons@4.4.0/build/font/octicons.min.css" />
Expand Down
2 changes: 1 addition & 1 deletion site/_layouts/page_submenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<br>
{% else %}
<li class="sidebar-nav-item"><a {% if link.url == url %}class="active"{% endif %}
href="{{site.baseurl}}{{layout.base}}{% if link.url != 'index' %}{{link.url}}.html{% endif %}" title="{{link.title}}">{{link.text}}
href="{{site.baseurl}}{{layout.base}}{{link.url}}.html" title="{{link.title}}">{{link.text}}
</a></li>
{% if link.sub-sidebar %}
<ul class="sub-sub-nav">
Expand Down
4 changes: 2 additions & 2 deletions site/_layouts/plain.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</div>
<div class="vl-links">
<div class="primary-links">
<a href="{{ site.baseurl }}/examples/" {% if page.menu == 'examples' %}class="active"{% endif %}>Examples</a>
<a href="{{ site.baseurl }}/examples/index.html" {% if page.menu == 'examples' %}class="active"{% endif %}>Examples</a>
<a href="{{ site.baseurl }}/tutorials/getting_started.html" {% if page.menu == 'tutorials' %}class="active"{% endif %}>Tutorials</a>
<a href="{{ site.baseurl }}/docs/" {% if page.menu == 'docs' %}class="active"{% endif %}>Documentation</a>
<a href="{{ site.baseurl }}/docs/index.html" {% if page.menu == 'docs' %}class="active"{% endif %}>Documentation</a>
<a href="{{ site.baseurl }}/usage/embed.html" {% if page.menu == 'usage' %}class="active"{% endif %}>Usage</a>
<a href="{{ site.baseurl }}/ecosystem.html" {% if page.menu == 'ecosystem' %}class="active"{% endif %}>Ecosystem</a>
</div>
Expand Down