Better control over runnable examples
See original GitHub issueRight now, the JS script in the page relies on a test to define if the code of an example should be runnable or not: contains search.addWidget
? or /function renderFn\(\S+(, isFirstRendering)?\) {/g.test(exampleContent)
?
This gives poor control over what’s runnable or not, which seems magical and also lead to inconsistent experience like the new calendar guide. In this guide, we have one runnable example while the others are not. Given the context, none should be runnable in the guide.
Options could be:
- have a way to specify runnable js
- have a front matter option for setting if the js examples on the page should be runnable
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Implementing a Runnable vs Extending a Thread | Baeldung
Learn why implementing Runnable is a better approach than extending Thread class.
Read more >Java Runnable Example - Examples Java Code Geeks - 2022
In this example, we will take a look into the Runnable interface in Java, and how it can be used in association with...
Read more >Write Asynchronous Code in Java using Runnable Threads ...
Creating and deciding when to run our threads gives you more control over what your application does. That may not sound intuitive, ...
Read more >"implements Runnable" vs "extends Thread" in Java
Yes: implements Runnable is the preferred way to do it, IMO. You're not really specialising the thread's behaviour. You're just giving it ...
Read more >Runnable Interface in Java - Javatpoint
The runnable class is used to perform multi-thread programming, especially in server-side as a server may be getting several requests from different clients....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here are the solutions that I see with their pros and cons:
1. In the frontmatter
Example
Pros
Cons
2. As a comment/annotation in the code itself
Example
Pros
Cons
3. As a new Markdown language
We can create an extension to our Markdown parser to create a runnable JavaScript language.
Example
Pros
Cons
4. As an HTML Element
Example
Pros
Cons
For now, I’d say that the frontmatter solution (1) is the easiest to implement.
Yes! What default behavior do we want? (runnable or not runnable)
Having it not runnable by default would be annoying as we’d have to update most of the guides and docs.