elvish/website
Qi Xiao 204bf524a7 pkg/elvdoc: Move directives to the top of comment blocks.
Also support unknown directives.
2024-03-22 14:55:02 +00:00
..
blog website: Use sentence case for most article titles. 2024-03-04 19:41:49 +00:00
cmd pkg/elvdoc: Move directives to the top of comment blocks. 2024-03-22 14:55:02 +00:00
favicons website: Restructure directory. 2020-06-14 13:56:58 +01:00
fonts website: Serve fonts as individual files. 2021-11-10 23:43:44 +00:00
get website/get: Support selecting TUNA's mirror. 2024-02-29 09:40:55 +00:00
home website: Style tweaks. 2024-02-28 18:32:40 +00:00
learn website: Fix broken relative link. 2024-03-14 23:54:19 +00:00
ref website: Document the Alt-* keys in readline-binding. 2024-03-14 18:36:30 +00:00
tools website: Revamp homepage, site-wide styles and ttyshots. 2024-02-26 18:23:16 +00:00
.gitignore website: Update .gitignore and add ttyshot files back. 2024-02-28 16:15:03 +00:00
gen-fonts.elv website: Serve fonts as individual files. 2021-11-10 23:43:44 +00:00
go.mod website: Run "go mod tidy". 2024-02-28 16:13:04 +00:00
go.sum website: Run "go mod tidy". 2024-02-28 16:13:04 +00:00
home.md Add Discord badge to README, and rearrange the orders. 2024-03-04 12:28:52 +00:00
icon-font.css website: Revamp homepage, site-wide styles and ttyshots. 2024-02-26 18:23:16 +00:00
index.toml website: Revamp homepage, site-wide styles and ttyshots. 2024-02-26 18:23:16 +00:00
Makefile website: Revamp homepage, site-wide styles and ttyshots. 2024-02-26 18:23:16 +00:00
README.md website: Revamp homepage, site-wide styles and ttyshots. 2024-02-26 18:23:16 +00:00
reset.css _website -> website. 2019-12-23 20:04:14 +00:00
style.css website: New series of articles: Beginner's Guide to Elvish. 2024-03-14 21:52:02 +00:00
template.html website: Fix canonical link for article pages. 2024-03-05 11:12:22 +00:00

Source for Elvish's website

This directory contains source for Elvish's official website.

The documents are written in CommonMark sprinkled with some HTML and custom macros. Most of them can be viewed directly in GitHub; notable exceptions are the homepage (home.md) and the download page (get/prelude.md).

Building

The website is a collection of static HTML files, built from Markdown files with a custom toolchain. You need the following software to build it:

  • Go, with the same version requirement as Elvish itself.

  • GNU Make (any "reasonably modern" version should do).

To build the website, just run make. The built website is in the _dst directory. You can then open _dst/index.html or run an HTTP server within _dst to preview.

NOTE: Although the website degrades gracefully when JavaScript is disabled, local viewing works best with JavaScript enabled. This is because relative paths like ./get will cause the browser to open the corresponding directory, instead of the index.html file under it, and we use JavaScript to patch such URLs dynamically.

Additional workflows

  • Run make check-rellinks to ensure that relative links between pages are valid.

  • Run make Elvish.docset to build a docset containing all the reference docs. Docset is a format for packaging documentation for offline consumption.

Both workflows use a Python script under the hood, and require Python 3 and Beautiful Soup 4 (install with pip install --user bs4).

Transcripts

Documents can contain transcripts of Elvish sessions, identified by the language tag elvish-transcript. A simple example:

```elvish-transcript
~> echo foo |
   str:to-upper (one)
▶ FOO
```

When the website is built, the toolchain will highlight the echo foo | str:to-upper (one) part correctly as Elvish code.

To be exact, the toolchain uses the following heuristic to determine the range of Elvish code:

  • It looks for what looks like a prompt, which starts with either ~ or /, ends with > and a space, with no spaces in between.

  • It then extends the range downwards, as long as the line starts with N whitespaces, where N is the length of the prompt (including the trailing space).

As long as you use Elvish's default prompt, you should be able to rely on this heuristic.

Ttyshots

Some of the pages include "ttyshots" that show the content of Elvish sessions. They are HTML files with terminal attributes converted to CSS classes, generated from corresponding instruction files. By convention, the instruction files have names ending in -ttyshot.elvts (because they are syntactically Elvish transcripts), and the generated HTML files have names ending in -ttyshot.html.

The generation process depends on tmux and a built elvish in PATH. Windows is not supported.

Instruction syntax

Ttyshot instruction files look like Elvish transcripts, with the following differences:

  • It should not contain the output of commands. Anything that is not part of an input at a prompt causes a parse error.

  • If the Elvish code starts with # followed immediately by a letter, it is treated instead as a command to sent to tmux.

    The most useful one (and only one being used now) is send-keys.

For example, the following instructions runs cd /tmp, and sends Ctrl-N to trigger navigation mode at the next prompt:

~> cd /tmp
~> #send-keys C-N

Generating ttyshots

Unlike other generated website artifacts, generated ttyshots are committed into the repository, and the Makefile rule to generate them is disabled by default. This is because the process to generate ttyshots is relatively slow and may have network dependencies.

To turn on ttyshot generation, pass TTYSHOT=1 to make (where 1 can be replaced by any non-empty string). For example, to generate a single ttyshot, run make TTYSHOT=1 foo-ttyshot.html. To build the website with ttyshot generation enabled, run make TTYSHOT=1.

The first time you generate ttyshots, make will build the ttyshot tool, and regenerate all ttyshots. Subsequent runs will only regenerate ttyshots whose instruction files have changed.

Commit History

These files used to live in a separate repository. However, because @xiaq did not merge the repositories in the correct way (he simply copied all the files), the commit history is lost. Please see that repository for a full list of contributors.