Skip to content

[docs] add sl-shell-example syntax-highlighting language#264

Closed
shish wants to merge 1 commit into
facebook:mainfrom
shish:pr264
Closed

[docs] add sl-shell-example syntax-highlighting language#264
shish wants to merge 1 commit into
facebook:mainfrom
shish:pr264

Conversation

@shish

@shish shish commented Nov 24, 2022

Copy link
Copy Markdown
Contributor

Stack created with [Sapling]

[docs] add sl-shell-example syntax-highlighting language

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

Screenshot 2022-11-24 at 16 15 08

(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:
Screenshot 2022-11-24 at 15 54 27

After:
Screenshot 2022-11-24 at 15 54 39

@shish

shish commented Nov 24, 2022

Copy link
Copy Markdown
Contributor Author

If somebody is some kind of regex-genius it might even be possible to automatically highlight smartlog examples, but I'll leave that as an exercise for the reader (or my future self :) )

@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@mzr

mzr commented Nov 24, 2022

Copy link
Copy Markdown
Contributor

Thanks for the PR! LGTM, but one nit from me. Can we change sl-session to something like sl-shell-example? IMO it better reflects what it really is, and it is also similar to the original shell-session in Prism.

@shish shish changed the title [docs] add sl-session syntax-highlighting language Nov 24, 2022
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shish has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shish has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shish has updated the pull request. You must reimport the pull request before landing.

@shish

shish commented Nov 24, 2022

Copy link
Copy Markdown
Contributor Author

Can we change sl-session to something like sl-shell-example?

Done :)

@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

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">
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shish has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

facebook-github-bot pushed a commit that referenced this pull request Dec 1, 2022
Summary:
Stack created with [Sapling]
* #270
* __->__ #267
* #266
* #264

[docs] syntax-highlighting for smartlogs

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:
{F806537223}

Pull Request resolved: #267

Test Plan: Looked through all of the pages manually

Reviewed By: quark-zju

Differential Revision: D41544319

Pulled By: shish

fbshipit-source-id: 1a3bf691a5f53de90c4bb36a4c2613cf1a5edb0c
facebook-github-bot pushed a commit that referenced this pull request Dec 5, 2022
Summary:
Stack created with [Sapling]
* #270
* #267
* __->__ #266
* #264

[docs] Regenerate command auto-docs

 I want to add syntax highlighting to the auto-generated docs, but they are out of date, so first let's update them

Pull Request resolved: #266

Reviewed By: bolinfest

Differential Revision: D41544316

Pulled By: shish

fbshipit-source-id: f6523275073add5a90982963089012e46f516d29
facebook-github-bot pushed a commit that referenced this pull request Dec 6, 2022
Summary:
Stack created with [Sapling]
* __->__ #269
* #267
* #266
* #264

[docs] make examples consistent

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

Pull Request resolved: #269

Test Plan: manually looked through every page

Reviewed By: bolinfest

Differential Revision: D41544321

Pulled By: shish

fbshipit-source-id: aca88968b1c6cfc5340a004dd115e9eabbd4313c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants