이번주에 우리는 홈페이지 electron.atom.io 에 Electron 문서를 추가하였습니다. /docs/latest 에서 최신 문서를 볼 수 있습니다. 또한, 이전 버전의 문서도 유지할 것 입니다. /docs/vX.XX.X 에서 사용중인 버전의 문서를 확인하세요.
You can visit /docs to see what versions are available or /docs/all to see the latest version of docs all on one page (nice for cmd
+ f
searches).
If you’d like to contribute to the docs content, you can do so in the Electron repository, where the docs are fetched from. We fetch them for each minor release and add them to the Electron site repository, which is made with Jekyll.
If you’re interested in learning more about how we pull the docs from one repository to another continue reading below. Otherwise, enjoy the docs!
We’re preserving the documentation within the Electron core repository as is. This means that atom/electron will always have the latest version of the docs. When new versions of Electron are released, we duplicate them over on the Electron website repository, atom/electron.atom.io.
To fetch the docs we run a script with a command line interface of script/docs vX.XX.X
with or without the --latest
option (depending on if the version you’re importing is the latest version). Our script for fetching docs uses a few interesting Node modules:
nugget
for getting the release tarball and saving it to a temporay directory.gunzip-maybe
to unzip the tarball.tar-fs
for streaming just the /docs
directory from the tarball and filtering and processing the files (with the help of through2
) so that they work nicely with our Jekyll site (more on that below).Tests help us know that all the bits and pieces landed as expected.
The Electron website is a Jekyll site and we make use of the Collections feature for the docs with a structure like this:
electron.atom.io
└── _docs
├── latest
├── v0.27.0
├── v0.26.0
├── so on
└── so forth
For Jekyll to render each page it needs at least empty front matter. We’re going to make use of front matter on all of our pages so while we’re streaming out the /docs
directory we check to see if a file is the README.md
file (in which case it receives one front matter configuration) or if it is any other file with a markdown extension (in which case it receives slightly different front matter).
Each page receives this set of front matter variables:
---
version: v0.27.0
category: Tutorial
title: 'Quick Start'
source_url: 'https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md'
---
The README.md
gets an additional permalink
so that has a URL has a common root of index.html
rather than an awkward /readme/
.
permalink: /docs/v0.27.0/index.html
In the site’s _config.yml
file a variable latest_version
is set every time the --latest
flag is used when fetching docs. We also add a list of all the versions that have been added to the site as well as the permalink we’d like for the entire docs collection.
latest_version: v0.27.0
available_versions:
- v0.27.0
collections:
docs: {output: true, permalink: '/docs/:path/'}
The file latest.md
in our site root is empty except for this front matter which allows users to see the index (aka README
) of the latest version of docs by visiting this URL, electron.atom.io/docs/latest, rather than using the latest version number specifically (though you can do that, too).
---
permalink: /docs/latest/
redirect_to: /docs/1.4.1
---
In the docs.html
layout template we use conditionals to either show or hide information in the header and breadcrumb.
{% if page.category != 'ignore' %}
<h6 class='docs-breadcrumb'>{{ page.version }} / {{ page.category }}
{% if page.title != 'README' %} / {{ page.title }} {% endif %}</h6>
{% endif %}
To create a page showing the versions that are available we just loop through the list in our config on a file, versions.md
, in the site’s root. Also we give this page a permalink: /docs/
{% for version in site.available_versions %}
- [{{ version }}](/docs/{{ version }})
{% endfor %}
Hope you enjoyed these technical bits! If you’re interested in more information on using Jekyll for documentation sites, checkout how GitHub’s docs team publishes GitHub’s docs on Jekyll.
이 글에 피드백이 있나요? @ElectronJS 트위터에서 알려주세요.
도움이 필요하거나 버그를 찾으셨나요? Contact us.