Skip to content

[docs] make examples consistent#269

Closed
shish wants to merge 4 commits into
facebook:mainfrom
shish:pr269
Closed

[docs] make examples consistent#269
shish wants to merge 4 commits into
facebook:mainfrom
shish:pr269

Conversation

@shish

@shish shish commented Nov 25, 2022

Copy link
Copy Markdown
Contributor

Stack created with [Sapling]

[docs] make examples consistent

Summary: both human understanding and syntax highlighting work better when the examples are consistent :)

Test Plan: manually looked through every page

Summary: Right now the example sl sessions have no hightlighting, or sometimes they pretend to be bash, which kind-of-half-works but also half doesn't work and is ugly (See the "Before" example - there is random highlighting for some numbers in the middle of command output, the ".." in "..." is randomly highlighted as a directory, etc)

This diff adds a new custom Prism language called "sl-shell-example" which does syntax highlighting specifically tailored for our example sessions with these main parts:

```
# comment
$ shell command
~/my/subdir $ shell command in a specific subdirectory
output
```

<img width="495" alt="Screenshot 2022-11-24 at 16 15 08" src="https://user-images.githubusercontent.com/40659/203828858-592f3bbd-27bb-42c5-a762-881baed3ac21.png">

(For the record, Prism already has a language called "shell-session", but that language doesn't support comments (which is something we make heavy use of), and also it tries to be clever by highlighting random words in the middle of shell commands (which is just distracting in the context of sapling docs))

Test Plan:

Before:
<img width="667" alt="Screenshot 2022-11-24 at 15 54 27" src="https://user-images.githubusercontent.com/40659/203827808-2dd856ef-4a94-4afe-ac79-f053925f3e59.png">

After:
<img width="668" alt="Screenshot 2022-11-24 at 15 54 39" src="https://user-images.githubusercontent.com/40659/203827793-3d1cee6b-0c68-4a99-9db9-821162db530e.png">
Summary: I want to add syntax highlighting to the auto-generated docs, but they are out of date, so first let's update them

Test Plan:
This doesn't work in all cases (trying to come with with a regex that correctly handles practically arbitrary input never will) - but it seems to cover the majority of examples that are in the docs in practice.

Notable omissions:
- non-active local bookmarks aren't spotted
- no differentiation between draft and public commits

Example:
<img width="597" alt="Screenshot 2022-11-25 at 15 22 48" src="https://user-images.githubusercontent.com/40659/204015254-0fa62795-d39e-4c0a-bd49-81102872d837.png">
Summary: both human understanding and syntax highlighting work better when the examples are consistent :)

Test Plan: manually looked through every page
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@sggutier has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants