Commit Graph

85 Commits

Author SHA1 Message Date
goodfirm
e3bf7189dd chore: fix function names in comment
Signed-off-by: goodfirm <fanyishang@yeah.net>
2024-04-10 11:10:58 +01:00
Qi Xiao
bf2eb50ba8 pkg/elvdoc: Move support of "doc:id" into website/cmd/md2html.
Also change the spelling to "doc:html-id" as this is only relevant for HTML outputs.
2024-03-22 15:06:19 +00:00
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
Qi Xiao
1412473b4a website: Revamp homepage, site-wide styles and ttyshots.
- Homepage revamp:

  - Rewrite the homepage in a linear format of sections, with every other
    section styled with full-width gray background.

  - The first section is a short intro, with big buttons for "download" and
    "learn".

  - Create a new "case studies" page to house the explainers for the examples.

- Site-wide styles:

  - Restyle code blocks and ttyshots, using a more subtle gray border box
    instead of gray background.

  - Support headers for code blocks and ttyshots, in a style that vaguely
    resembles title bars of desktop windows. In Markdown sources, additional
    content after the language tag becomes the header.

  - Reorganize the global stylesheet and template, including using 2 spaces for
    indentation and putting dark mode color rules next to the light mode rules.

  - Change debug hotkey to toggle dark mode to Shift-D.

- Ttyshots:

  - Handle trailing spaces in more places in the ttyshot tool - there seems to
    be more of them in the latest tmux version.

  - Base the ttyshot tool's parser on pkg/transcript.

  - Support per-ttyshot cols and rows.

  - Rename x.elvts and x.ttyshot.html to x-ttyshot.elvts and x-ttyshot.html.

  - Change the syntax from "@ttyshot filename" to code block with a special
   "ttyshot" language tag to work better with the header syntax.
2024-02-26 18:23:16 +00:00
Qi Xiao
3b27569e2c pkg/elvdoc: Remove support for "#doc:fn".
This construct is only used in two places - grouping numerical comparison
commands together and grouping string comparison commands together. However,
grouping them together makes it impossible to look up their individual elvdocs,
for example using "doc:show '<'", so abandon this half-baked grouping mechanism.

In future a more general mechanism to group symbols together may be introduced.

Document != and !=s as if they only take two arguments, addressing #1767. The
actual change will be done in a separate commit.
2024-02-18 10:47:17 +00:00
Qi Xiao
3387f454b7 pkg/elvdoc: Change the semantics of Entry.{Name Content}
The Name field now contains the qualified name, with the "$" prefix for variables.

The Content field no longer contains the usage text for functions. That is now
stored in a separate Fn field, and the FullContent method now returns what used
to be the Content field.
2024-02-17 18:43:11 +00:00
Qi Xiao
e74cda7bc3 website/cmd/md2html: Reduce dependency on Elvish packages.
This command used to depend on pkg/mods/doc to access the embedded .elv, which
in turn depends on all the packages that implement builtin modules. The latter
set of packages depends on almost all the Elvish packages transitively. As a
result, almost any change in any Elvish package will trigger a rebuild of this
command and the whole website.

This commit minimizes the dependency on Elvish packages by having it read the
.elv files during runtime instead (enabled by
9112eb1ab2).

Additionally:

- Move HighlightCodeBlock, needed by website/cmd/md2html, from pkg/mods/doc
  to pkg/elvdoc. Moving it is necessary to completely remove the dependency of
  website/cmd/md2html on pkg/mods/doc.

- Remove the dependency of pkg/edit/highlight on pkg/eval. It only uses
  eval.UnpackCompilationErrors; move this work to the supplied Check function.
  This removes the transitive dependency of website/cmd/md2html on pkg/eval.

- Augment website/tools/md-deps to recognize @module lines and add dependency on
  the corresponding .elv files.
2024-01-09 13:36:57 +00:00
Qi Xiao
1cfe72a692 website/cmd/md2html: Fix [foo]() (unqualified) outside builtin.html.
This syntax has been documented to have an implicit destination of
builtin.html#foo, but it never worked correctly outside builtin.html itself.

Also do some minor cleanups of the package, including removing bogus package
godocs that were inherited from the previous version where the components were
separate programs.
2024-01-08 22:45:28 +00:00
Qi Xiao
ba8614bab3 website: Overhaul styling.
Also rewrite some texts to fit within the now narrower body.
2023-04-29 16:55:10 +01:00
Qi Xiao
c0d5b015d0 website: Reduce the width of ttyshots.
This is to prepare for a stylesheet overhaul that will reduce the width of the
body text.

Also change home/pipelines.elvts to use XKCD instead, which is a bit more
interesting than GitHub and makes for a shorter URL.
2023-04-24 21:34:05 +01:00
Qi Xiao
0adf0ec147 Use the unix build tag.
The unix build tag is supported by Go 1.19.
2023-03-03 00:01:26 +00:00
Qi Xiao
08007a52ce website/cmd/md2html: Support implicit link targets to elvdoc sections.
For example, [`put`]() links to the elvdoc for "put".

Also remove the @cf macro now that implicit targets make it easier to link to
other elvdoc sections.
2023-01-02 02:36:58 +00:00
Qi Xiao
dbb41af2d8 pkg/mods/doc: Highlight elvish and elvish-transcript code in doc:show.
Also:

- Simplify the API for handling code blocks in md.{HTML TTY}Codec.

- Remove the "elvish-bad" language; it is only used in one place.
2023-01-02 01:01:27 +00:00
Qi Xiao
9f7312a802 pkg/ui: Improve API for Text.
- Add a TextBuilder for building a Text efficiently.

- Remove NormalizeText, and make functionsn this package always return already
  normal Text instances.

- Rename Style.{Foreground Background} to Fg and Bg.

- Fix the Repr output of both Text and Segment.
2023-01-02 01:00:26 +00:00
Qi Xiao
5d00ab1265 website: Integrate cmd/macros into cmd/md2html. 2023-01-01 17:53:23 +00:00
Qi Xiao
92a7428138 website: Integrate cmd/elvdoc into cmd/macros. 2023-01-01 17:42:08 +00:00
Qi Xiao
f2aeab0362 website/cmd/elvdoc: Simplify the implementation by using pkg/mods/doc. 2022-12-31 23:07:13 +00:00
Qi Xiao
8be968a53b website: Integrate cmd/highlight into cmd/md2html. 2022-12-31 00:54:11 +00:00
Qi Xiao
02cb139441 website/cmd/md2html: Move the codec into a separate file. 2022-12-30 14:02:00 +00:00
Qi Xiao
098e0ed863 pkg/elvdoc: Don't HTML-escape function usage.
Code blocks in CommonMark don't support HTML entities, so they shouldn't be HTML-escaped.

This bug causes HTML entities to show up in the output of doc:show, which
(correctly) does not interprete HTML entities. It was previously masked earlier
by website/cmd/highlight HTML-unescaping code blocks; fix the latter too.
2022-12-27 11:59:09 +00:00
Qi Xiao
dc523d45be website: Preserve $ in the HTML ID of docs for variables.
We are no longer using Pandoc, so this limitation can be lifted.

Also make @cf generate internal links where applicable in non-builtin modules:
"@cf mod:fn" in the doc of "mod" now links to just "#mod:fn" instead of
"mod.html#mod:fn".
2022-11-22 23:42:19 +00:00
Qi Xiao
980cf009ca Parse comment blocks preceding var and fn declarations as doc comments.
Convert all .elv files (including .d.elv files) to use this new format.
2022-11-22 22:59:31 +00:00
Qi Xiao
0203a2ad82 website/cmd/elvdoc: Fix a bug handling comment blocks from multiple files. 2022-11-19 21:47:31 +00:00
Qi Xiao
810b3486d8 Expand the godoc of pkg/md to include a lot more context.
Also link to it from the godoc of the commands that use it.
2022-11-11 20:25:33 +00:00
Qi Xiao
ffd2152a19 website: Use a pkg/md-based HTML renderer.
Pandoc is no longer required to build the website.
2022-11-08 13:59:30 +00:00
Qi Xiao
58fabebc09 website/cmd/ttyshot: Update package godoc. 2022-08-10 20:02:44 +01:00
Qi Xiao
82a72e31e3 website: Make ttyshots look like transcripts.
This further simplifies the op structure - only code input and tmux commands are
necessary now; waiting for prompts is now implicit.
2022-08-09 13:44:11 +01:00
Qi Xiao
551e246d96 webiste/cmd/macros: Strip leading $ from anchor targets of @cf.
Also add previously missing $'s in @cf arguments. This doesn't matter for the
anchor target, but matters for the link text.
2022-08-08 00:09:17 +01:00
Qi Xiao
c45a6f5ae4 website/cmd/highlight: Recognize more prompts in transcripts.
Instead of a hardcoded "~> ", recognize anything starting with ~ or /, followed
by any non-spaces, and ending with "> ". This should cover most prompts as long
as the directory name doesn't contain spaces, and hopefully has no false
positive.
2022-08-07 22:42:39 +01:00
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