Commit Graph

56 Commits

Author SHA1 Message Date
Qi Xiao
2e788c846d Run gofmt.
https://tip.golang.org/doc/go1.19#go-doc
2022-08-07 22:30:11 +01:00
Qi Xiao
fc3dcaf883 website: Move ttyshots to be side by side with markdown files.
Also rewrite the documentation.
2022-08-04 23:38:58 +01:00
Qi Xiao
1da19a0b03 website/cmd/ttyshot: Various small tweaks.
- Remove all content before "[CUT]". This allows the ttyshot spec to remove part
  of setup.

- Use a edit:max-height value of 15, to generate ttyshots with size consistent
  with the original ones.

- Add more entries to directory history to get more lines in the history listing
  ttyshot.

- Adjust specs for the ttyshots on the home page to get the ttyshots have the
  same height.
2022-08-04 21:38:34 +01:00
Qi Xiao
98218b5cba website/cmd/ttyshot: Remove most setup.
Ttyshots should be as close to the "vanilla" state of Elvish as possible.
2022-08-04 20:57:39 +01:00
Qi Xiao
704c3abbdf website/cmd/ttyshot: Strip trailing empty prompts.
Also add an implicit #prompt op if the last op is opText.
2022-08-04 13:00:19 +01:00
Qi Xiao
82551c6b80 website/cmd/ttyshot: Simplify opcode set.
Only opText, opPrompt and opTmux are needed now.
2022-08-04 10:45:13 +01:00
Qi Xiao
10ae6d6bb3 website/cmd/ttyshot: Add new #send-keys command.
This will just run tmux send-keys. It will replace all the other commands that send keys.

Also add more logging and error handling code.
2022-08-04 10:45:13 +01:00
Qi Xiao
64cf4b805e website/cmd/ttyshot: Drain tmux output before waiting for it to exit. 2022-08-04 10:45:13 +01:00
Qi Xiao
9d5cdb8359 website/cmd/ttyshot: Change op leader from // to #.
Lines that start with # that is not followed by a space is taken to be an op.

This is a first step to make ttyshot specs (mostly) valid Elvish scripts.
2022-08-04 10:45:13 +01:00
Qi Xiao
e089bbc4b0 website/cmd/ttyshot: Remove wait-for-{str,re}.
The wait-for-str op is no longer needed since the ttyshot procedure will now end
gracefully.

The wait-for-re op seems to never been used in the first place.

Also add a -v flag that enables verbose logging, although there is no logging
call yet.
2022-08-04 10:45:13 +01:00
Qi Xiao
8b8652b40e website: Restore ttyshot width to 58.
Also tweak edit:navigation:width-ratio and the fake home directory to make
everything just fit in the navigation mode ttyshot.
2022-08-03 00:07:08 +01:00
Qi Xiao
262ca12d3e website/cmd/ttyshot: Fix handling of SGR inverse.
See comment in interp.go for details.
2022-08-02 23:41:51 +01:00
Qi Xiao
58e085eba4 website/cmd/ttyshot: Improve HTML output.
- Handle newlines correctly, in case they appear in the middle of a segment.

- Don't wrap unstyled segments in <span>.

- Strip unstyled trailing spaces.

- Don't escape ' and " - they are pretty frequent, and not escaping them makes
  it slightly easier to read diffs.

Also fix a bug in waitForOutput when budget is exactly 0.
2022-08-02 23:12:14 +01:00
Qi Xiao
e4100d36de website/cmd/ttyshot: Only build on Unix.
The pty library, as well as tmux, already only works on Unix (it compiles but
will always return an error).
2022-08-02 22:22:46 +01:00
Qi Xiao
3798754dfe website/cmd/ttyshot: Simplify implementation of wait-* ops.
No need to relay a file to a channel in order to be able to read from it with a
timeout; just use select(2) (wrapped by eunix.WaitForRead).
2022-08-02 22:14:35 +01:00
Qi Xiao
0b1d1c3eae website/cmd/ttyshot: Various cleanups.
Also remove the unused "sleep" op.
2022-08-02 21:52:13 +01:00
Qi Xiao
052c5f4b7d website/cmd/ttyshot: Take output and raw file paths as flags.
- Move the output writing to the end. This avoids putting the output file in a
  truncated state while the ttyshot process is running.

- Don't save raw output of capture-pane unless the -save-raw flag is given.
2022-08-01 13:16:33 +01:00
Qi Xiao
4227d49708 website/cmd/ttyshot: Simplify setup of temp home.
- Use a fork of testutil.ApplyDir to specify the layout in a map

- Hardcode the elvish directory's layout, remove cp-elvish.sh

- Put rc.elv where Elvish expects to find it

- Place temporary files in a hidden .tmp directory
2022-08-01 10:51:48 +01:00
Qi Xiao
0217df2852 website/cmd/ttyshot: Remove database setup code.
Just rely on the Elvish daemon to create the database.
2022-08-01 09:58:49 +01:00
Qi Xiao
b9023c58c0 website/cmd/ttyshot: Simplify tmux startup.
- Start with an empty environment, only setting HOME, PATH and TERM

- Use -T to force terminal features, removing the need for a dedicated tmux.conf
  file
2022-08-01 09:52:44 +01:00
Qi Xiao
7a621c2c69 website/cmd/ttyshot: Remove the trim-empty op. 2022-07-31 22:52:08 +01:00
Qi Xiao
10ee634b7a website/cmd/ttyshot: Simplify prompt handling.
The before-readline hook now just writes out "[PROMPT]", and the //prompt op now
just waits for "[PROMPT]" to appear.

Also strip all the prompt markers from the output.
2022-07-31 22:39:10 +01:00
Qi Xiao
b541db9d4f website/cmd/ttyshot: Pass -N to capture-pane.
The thumb part of scroll bars are rendered with stylized spaces. The
capture-pane command strips trailing spaces by default and will remove those
parts.
2022-07-31 21:56:39 +01:00
Qi Xiao
0b29a7e213 website/cmd/ttyshot: Use a very high tmux tty.
- Always trim trailing newlines.

- The UI's size is now limited by edit:max-height instead.
2022-07-31 21:21:23 +01:00
Qi Xiao
ea8b6d84b0 website/cmd/ttyshot: Shut down gracefully.
Instead of using tmux kill-session, bound Alt-q to a key that runs capture-pane
and then exits.

Tmux can now be expected to exit without error, and there is no longer a need to
hardcode a 100ms for the ttyshot to stablize.
2022-07-31 18:14:04 +01:00
Qi Xiao
aeff3dc07b website/cmd/ttyshot: Make cmdNum a local variable. 2022-07-31 17:35:21 +01:00
Qi Xiao
aa364130d1 website/cmd/ttyshot: Embed scripts used for ttyshot.
This allows the command to be run from any directory.

Also fix the filenames of tmux.conf and rc.elv to get proper syntax highlighting
in editors.
2022-07-31 13:55:14 +01:00
Qi Xiao
3b7227cb39 website/cmd/ttyshot: Remove master/slave terminology.
The master/slave terminology is now increasingly shunned. The origin author of
the pty library has moved away from it back in 2019:
7dc38fb350

Unfortunately, renaming "master" to "pty" is problematic because it conflicts
with the package name. Use "ctrl" as a compromise - the same "ctrl" term is
already used in pkg/cli/clitest, in ttyCtrl.
2022-07-31 13:18:20 +01:00
Qi Xiao
b0be2674d7 website/cmd/ttyshot: Remove daemon startup code.
Elvish spawns a daemon on demand, there is no need to start it "manually" from
the ttyshot program.
2022-07-31 12:20:46 +01:00
Qi Xiao
00178848c9 website/cmd/ttyshot: Don't use log.Fatal to handle errors.
Defer functions do not run when using log.Fatal.
2022-07-25 20:25:53 +01:00
Qi Xiao
2fd5cad915 website/cmd/ttyshot: Split into 3 files.
Also reorder functions in top-down order.

This commit does not change the content of any of the functions.
2022-07-25 19:51:31 +01:00
Kurtis Rader
4b4726b9a6 Make ttyshots scripted and reproducible
The main benefits of this change are:

1) It uses a hermetic "home" directory with a known command and location
   history. Which means it no longer depends on the interactive history
   and directory layout of the person creating the ttyshot. Which also
   means it no longer leaks the private history of anyone creating a
   ttyshot. This produces reproducible results when updating ttyshots.

2) The user no longer has to augment the ttyshot by manually adding the
   output of the commands to the generated HTML file. A process that is
   error prone. The output of the commands that generate the ttyshot is
   now captured and automatically included in the resulting HTML.

3) It makes it trivial to recreate every ttyshot. Simply execute these
   commands:

   ```
   make ttyshot
   for f [website/ttyshot/**.spec] { put $f; ./ttyshot $f }
   ```

4) It makes it easy to introduce new "ttyshot" images by creating a
   shell session "spec" file. This makes it easy to replace the existing
   "```elvish-transcript...```" examples with ttyshots in order to
   ensure a consistent representation and visual consistency with the
   transcripts that are currently generated as ttyshots.

The downside of this change is the introduction of a dependency on the
Tmux application. But that seems reasonable since Tmux is a mature
application available on Linux, macOS, BSD, and probably every other
UNIX like OS we care about. Note that generating the Elvish
documentation already depends on similar apps such as Pandoc.

Related #1459
2022-06-19 10:51:29 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
6f97ad0e37 website: Remove support for the "all" category from gensite. 2022-01-02 00:51:28 +00:00
Qi Xiao
1c1227324e website: Revamp the learn index page.
- Split articles into groups.

- Add notes besides the entry for fundamentals and quick tour.
2022-01-01 16:34:05 +00:00
Qi Xiao
7a40cf1fea website: Rename the "genblog" tool to "gensite".
Also rename internal references to the "blog" to "site" when it refers to the site as the whole (instead of https://elv.sh/blog).
2022-01-01 12:10:26 +00:00
Qi Xiao
246706aeca website: Preserve ":" in elvdoc header IDs.
This fixes #1430.
2021-11-29 23:47:59 +00:00
Qi Xiao
7a32326a03 website: Avoid reflow with "font-display: block". 2021-11-11 17:19:30 +00:00
Qi Xiao
b49523345e website: Serve fonts as individual files.
Upsides:

- Removing the render-blocking fonts.css allows the page to be visible while the
  font is being loaded.

- The original WOFF2 files are smaller than the base64-encoded version in
  fonts.css.

- Browsers may be smart enough to not download fonts that are not needed.

The only downside is that this requires the browser to make more requests - up
to 6 for all 6 font files. But this is not a problem with modern browsers.
2021-11-10 23:43:44 +00:00
Qi Xiao
b5764ff820 URL-encode docset anchors.
Not encoding them is problematic for the / builtin.
2021-08-31 20:16:56 +01:00
Qi Xiao
ab59ef9062 Move bundled modules into .elv files.
- Use go:embed (available since Go 1.16) to embed them into the binary

- Teach elvdoc to support comments starting with #, and find *.elv when given a directory
2021-08-24 16:18:30 +01:00
Qi Xiao
47de83c7d1 Reorganize standard library modules.
- Move from pkg/eval/mods to pkg/mods

- Introduce mods.AddTo that adds all standard library modules

- Move epm and readline-binding into their own packages
2021-08-24 15:56:04 +01:00
Qi Xiao
9076934395 Remove most uses of the ioutil package.
https://golang.org/doc/go1.16#ioutil
2021-08-23 00:36:26 +01:00
Qi Xiao
c849d83164 Fix test of website/cmd/elvdoc, and add it to CI and the test target.
The website directory is a separate Go module, so it's not included by ./... and
tests there have to be run explicitly.
2021-08-21 16:51:19 +01:00
Qi Xiao
7d435154f5 Move doc for the epm module into its source. 2021-06-14 22:48:10 +01:00
Qi Xiao
e177b680ab Remove the -dir flag of elvdoc.
The command now automatically expands directory paths into $dir/*.go.
2021-06-14 22:40:42 +01:00
Qi Xiao
97c9f73559 Replace the @elvdoc macro with a @module macro.
The @module macro is placed at the beginning of a doc, and calls elvdoc after
processing the doc.

This is needed in order to correctly put the Module anchor at the beginning of
the doc, instead of at the place that calls @elvdoc.

Also refactor the macros command to reduce boilerplate in macro implementations.
2021-06-14 22:17:07 +01:00
Qi Xiao
7626616abf Remove navbar and hide ToC in docset files.
This is implemented by using an environment variable ELVISH_DOCSET_MODE to
control the template.
2021-06-13 01:46:27 +01:00
Qi Xiao
16dd9b6c34 Add scripts for generating Docset.
Docset is a format for offline docs: https://kapeli.com/docsets.

This addresses #1336.
2021-06-13 01:20:58 +01:00
Qi Xiao
4612b58759 Support exact integer and rational numbers. 2021-04-04 00:58:53 +01:00