Skip to content

feat: support for tryit buttons that send snippets to live vscode editor. - #101

Merged
gebner merged 22 commits into
leanprover:masterfrom
lovettchris:clovett/tryit
Feb 17, 2022
Merged

gebner merged 22 commits into
leanprover:masterfrom
lovettchris:clovett/tryit

Conversation

@lovettchris

@lovettchris lovettchris commented Jan 12, 2022 •

Copy link
Copy Markdown

Fixes #47

Dependent on latest version of mdbook and a new build of the book being published with that version of book.js: See leanprover/mdBook#6 which is now merged.

  1. It has a temporary redirect to http://lovettsoftware.com/theorem_proving_in_lean4/introduction.html until we get the new bits published on https://leanprover.github.io/theorem_proving_in_lean4/.
TryItDemo3.mp4

@gebner

gebner commented Jan 27, 2022

Copy link
Copy Markdown
Member
  • The reference manual opens in the browser, not in vscode.
  • The "Example" link opens a file that doesn't compile.
  • The TPIL4 font is light gray (on white background) and the copy button doesn't open the file in vscode (but I guess that's because the documentation hasn't been updated yet):
    grayfontcolor
  • The back button doesn't work in TPIL4.

@lovettchris

lovettchris commented Jan 27, 2022 •

Copy link
Copy Markdown
Author
  1. I fixed the reference manual link to run inside vscode.
  2. The "Example" link is a placeholder for a new "lean4-samples" repo that Leo is creating.
  3. I redirected the theorem proving book to http://lovettsoftware.com/theorem_proving_in_lean4/introduction.html so you can see how it is supposed to look until we get the official bits published.

I updated the intro demo video to also show how theme changes are now being tracked nicely.

@gebner

gebner commented Jan 31, 2022

Copy link
Copy Markdown
Member

It's a bit awkward that we have to have such a tight integration with the mdbook tool. Users also want to use their custom documentation generators; e.g. sphinx is fairly popular. But we can add support for that when the time comes.

I was actually really surprised to see these kind of theming issues here. I didn't recall any such issues from the Lean 3 extension. It turns out that sphinx themes set both background and color properties, which override the properties set by vscode.

Let's wait with merging until we can switch to the official links for TPIL4 and the reference manual.

The back button still doesn't work btw. I think you just need to increase the z-index.

@lovettchris

lovettchris commented Feb 1, 2022 •

Copy link
Copy Markdown
Author

I was actually really surprised to see these kind of theming issues here. I didn't recall any such issues from the Lean 3 extension. It turns out that sphinx themes set both background and color properties, which override the properties set by vscode.

I'm confused, what theming issues? Were you expecting the mdbook themes to pickup the vscode themes automatically or something? Do you know how that was supposed to work? I couldn't see anything in the mdbook styles that would do that. And the mdbook styles default to "navy" but "coal" looks better in VSCode... Hence the translation thunk that I'm adding with the vscode themes.js overrides. I also don't know a more general way of doing acquireVsCodeApi. Most "webview" hosting apps provide a callback api like this that you can call "sendMessage" on, but I'm not aware of a general pattern across all hosts are you? Sometimes you can inject javascript callbacks, but that requires taking a dependency on the same javascript runtime...

@lovettchris

Copy link
Copy Markdown
Author

The back button still doesn't work btw. I think you just need to increase the z-index.

Fixed.

@gebner

gebner commented Feb 1, 2022

Copy link
Copy Markdown
Member

I'm confused, what theming issues?

Just the fact the we have to set the theme at all, and that the colors are awful otherwise. We didn't have to do that in Lean 3 (because the sphinx styles set explicit background and foreground colors).

I also don't know a more general way of doing acquireVsCodeApi. Most "webview" hosting apps provide a callback api like this that you can call "sendMessage" on

I'm not talking about extensibility on this side, we're not going to use the themes.js code outside of vscode. I am talking about the set_theme function, which is only implemented in (our special) fork of mdbook.

@gebner

gebner commented Feb 1, 2022

Copy link
Copy Markdown
Member

In any case, we can iterate on that extensibility later.

I'm just waiting for https://leanprover.github.io/lean4/doc/ and https://leanprover.github.io/theorem_proving_in_lean4/ to be upgraded to the new mdbook version before merging.

@lovettchris

Copy link
Copy Markdown
Author

BTW: I just tried Lean3 and the themes are wrong, so I'm guessing lean3 never tried to integrate with vscode themes like I have done in this PR:

image

@lovettchris

Copy link
Copy Markdown
Author

@gebner this PR is now ready to merge, Leo just published a new version of the TPIL book built using the new version of mdbook so it has the correct book.js that works nicely inside vs code now:

image

Comment thread vscode-lean4/src/docview.ts Resolved
Comment thread vscode-lean4/src/docview.ts Resolved
@gebner
gebner merged commit 43fbf73 into leanprover:master Feb 17, 2022
@lovettchris
lovettchris deleted the clovett/tryit branch February 17, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation view with "Try This" to run code snippets locally.

2 participants