facebook / facebook/docusaurus
Folding sections in code blocks
- Vorherrschende Sprache
- TypeScript
- Sterne
- 66.2k
- Forks
- 10k
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 52
Beschreibung
## 🚀 Feature
Allow irrelevant sections of code to be folded away in code samples.
## Have you read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/master/CONTRIBUTING.md#reporting-new-issues)?
Yes
## Motivation
Sometimes it's nice to be able to fold away irrelevant sections in a full code example, so that you can focus on the important parts.
## Pitch
For example, if I wrote a Rust function:
```rust
fn main() {
// sample:start
println!("hello!");
// sample:end
}
```
I'd want it to display as (note the indentation):
```rust
println!("hello!");
```
There would be a button on the code block to allow this to be expanded to the full code:
```rust
fn main() {
println!("hello!");
}
```
### Example: Kotlin's documentation
For a live example, you can check out the Kotlin docs. They seem to have a nice UI for unfolding examples. For example, [here is their documentation on defining variables](https://kotlinlang.org/docs/reference/basic-syntax.html#defining-variables):
- Folded:
- Unfolded:
- Markdown source:

Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.