-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RunKit embeds to Node documentation [WIP] #22831
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks so cool 😄
doc/api_assets/runkit.js
Outdated
@@ -0,0 +1,33 @@ | |||
(function () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make sure that this script and others are still using our eslint rules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing!
@nodejs/documentation @rubys |
Does |
From my local tests, no. So we need to address this upstream with a proposal for |
I'll take a quick look at it, hopefully there's some setting I can do on our end that doesn't require changing and then upgrading the package. |
There doesn't appear to be a simple way to do this, but it is a very simple change in the eslint-plugin-markdown code. I've filed the issue here and will be submitting the PR today: eslint/markdown#98 |
The two build failures can be reproduced locally by using the following command:
Essentially what this means is that |
424c763
to
fc8d800
Compare
@rubys do you know what is failing now? Everything checks out when I run locally (except for "missing subsystem"?). The title formatting seems to flip back and forth (and I do not get it locally). I did a force push to rebase with master, is there any chance that confuses travis? |
It is new commit linting in action:
Just edit the first commit title to something like:
|
fc8d800
to
6361ed8
Compare
@vsemozhetbyt: thanks! |
Sorry to turn this into node build system 101 for me, but the current failures seem unrelated to anything in my branch (and locally master fails make -j2 test as well). However, I see other PRs passing, so I'm not sure what I'm doing wrong. |
If you mean the status under this PR, this is often flaky. If you check CI itself, you can see it is OK: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/1228/ |
The failure of |
(To fix your local failures, you probably just need to rebase against current upstream/master. If that doesn't do it, the next most obvious likely problem is a bug in macOS Mojave that causes two or three tests to fail. And if that's not it...let's talk more.) |
Alright, so I have just issued a pull request to Currently this branch uses a fork of |
Quick update: |
I just published |
6361ed8
to
8699a7b
Compare
I've now changed it to use As all tests seem to now pass we'll try to get the cosmetic changes in this week (choosing which embeds, the theme, etc). |
It seems ESLint will be updated soon on master: #23904 |
Just wanted to provide a quick update here. The first part of what I mentioned is now complete, Node 14 is up and running on RunKit. The second portion s taking longer since we didn't predict that our work on fully separating RunKit embeds from the main site would throw off some CSPs for a number of sites. We're working with them to get that updated and that's why that piece is moving a bit slower. Hopefully will complete the last part of this very soon. |
8ae28ff
to
2935f72
Compare
Another very delayed update: we are doing our best to get existing users onto the new system that we created for the Node stuff, but its going slower than we hoped. As such, I figured it might be good to break this PR into two pieces, so that we can get some of the unrelated-to-RunKit benefits in sooner. Specifically, I've opened up this PR which only includes the syntax highlighting on compile stuff. I was very excited about this when I first put this PR together, and it saddens me that the rest of the changes blocked that from going live. This also means that it will be a lot easier to make sense of the RunKit specific changes in this PR. We are currently evaluating options as to how to have a "legacy" version of embeds up for non-Node users to hopefully decouple these events and finally let this go through. |
…le compile-time syntax highlighting 1. The page will load much faster since there is much less JavaScript taking place. 2. Users with slow connections or JavaScript turned off will still see highlighted code. 3. I've changed the allhtml.js code to look for a special comment instead of the script tag for where to put the contents.
Given that this is still a work in progress, I've converted the PR into a draft |
vx_lorstani1 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vx_lorstani1
@bnb Hi Tierney, thanks for following up! Unfortunately, a later PR to the docs undid some of the elements in that branch that were required for this one (totally innocently of course, they couldn't have known that those elements were necessary for a non-landed branch). It's not too difficult to get things back working, but we've been punting as the other component (RunKit supporting every version, not just the latest of every major version), will be shipping soon, which will actually remove some of the complexity in this PR. For some context, in this PR we currently have to take the extra step to only show the embed if the version of the docs matches the version we support on RunKit (IOW, if you load old minor/patch version docs, like say 16.3.0 instead of 16.3.1, we don't show the embed at all, as someone mentioned they'd think it was confusing if the embed was 16.3.1 but the docs was for 16.3.0). We thus need runtime logic to check the version, etc. However, very soon RunKit will just be able to load any version, and this logic can be removed. |
sick, happy to hear that. If you plan to tidy up this PR when that lands in RunKit, happy to leave this open. |
Yes, would definitely appreciate that, thank you! |
This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open. |
There's been little activity on this PR in a bit, so I'm marking this as "stalled." |
this pull is from 2018 omg |
Additional note: RunKit doesn't use the latest version of Node.js (it uses an LTS) so while it's good for older documentation, as new features are added to the latest version of Node.js, they'll be unable to work properly in RunKit. |
Unfortunately, this PR has been stalled for several months, and is now being closed. |
This addresses #21723.
This is functionally complete and only has a few cosmetic changes to be made hopefully, namely, choosing the the node examples to turn on in this initial run, and separately choosing the right syntax highlighting theme. I figured it was worth starting the discussion now as it touched a few minor other things, namely:
This change changes nodejs.org to syntax highlight examples at compile time instead of at runtime in the browser.
Previous to this change, the syntax highlighting on nodejs.org was done at runtime using two scripts that were included in the repo in their minified form,
sh_javascript.min.js
andsh_main.min.js
(which I believe remained untouched since they were originally committed 5 years ago). This made the the RunKit process a bit trickier than necessary, as we would have to first wait for the highlighting to finish before swapping in the RunKit embed. This had a number of other downsides though:With this change, we're using the standard
highlight.js
library, which makes it easy to change theme, and additionally means the many many C++ examples on nodejs.org are now syntax highlighted as well (hurray!). Beyond that, the examples will be highlighted instantly of course and it's kind of cool that with the RunKit change most people will actually be loading less JavaScript.As part of the change above, I've taken the standard hopscotch theme.
I have no particular strong feelings either way about this. Hopscotch seemed to fit well and I was going to translate the existing theme, but it seemed to only highlight keywords as green. I am happy to just do that as well, but hopscotch is very subtle too and, especially for the C++ examples for example, enhances readability. Again, I'm happy to directly translate the existing CSS, or alternatively, if anyone wants to just suggest any of the many many existing highlight.js themes I'm happy to switch to that.
OK, with that out of the way, the meat of the change:
This introduces the ability to add "runkit" to code blocks, turning them into runnable examples. For example:
The nice thing about this is that the examples continue to syntax highlight correctly in Github as Github just ignores everything after the initial language tag. As explained in the above bug, we're hoping to make this a major part of the full API redesign, but want to do some initial tests (scaling, etc.) on the current site. Currently this commit only includes a crypto example we know to work well, but we're hopefully going to be turning on around 5 - 10 total examples, which we'll be updating this PR with in the next couple of days.
A quick note on the way we've added RunKit: since there is only one template file used for every page, I've created a super tiny script that checks whether any example is runnable on load, and only then adds the runkit script tag. Again, since we're removing much more JavaScript than this already with the syntax highlighting change described above, this should improve load time overall. When we make the full API redesign, the ideal would be to include a defer-ed runkit script tag on pages that use it, and leave it out completely on those that don't.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes