google / google/comprehensive-rust

Examples with hidden lines should be editable

Open
#2,811 5 comments 0 reactions 1 assignee Claimed by @LukeMathWalker View on GitHub
deep_dives/idiomatic
Dominant language
Rust
Stars
33.4k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
10

Description

# Problem

For this issue, there are two types of code blocks:

- Read-only ones, defined via ` ```rust `
- Editable ones, defined via ` ```rust,editable `

Read-only code blocks support the usage of `#` to hide code from the view that's rendered in the browser:

Image

You can click on the "Eye" toggle to show the hidden lines:

Image

This makes it convenient to break an example across multiple code blocks without repeating content from the previous block (e.g., the definition of `UserId` in the example above).

Instructors often need to be able to edit code directly on the slide, but we lose the hiding feature if we mark the block as `editable`:

Image

The `UserId` definition is shown, even if it was prefixed with `#` in the source.

# Solution

Modify the theme to introduce a new button, next to the "Copy" one, which allows instructors to switch from "Preview" to "Edit" mode.
In "Preview" mode, code is rendered as if the `editable` attribute had not been included.
In "Edit" mode, all hidden code is shown and the instructor is free to edit.

We won't support going back from "Edit" to "Preview" mode.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.