Skip to content
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

Investigate how to hide lines in rendered code snippets #212

Open
2 tasks
cmichi opened this issue Apr 4, 2023 · 0 comments
Open
2 tasks

Investigate how to hide lines in rendered code snippets #212

cmichi opened this issue Apr 4, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@cmichi
Copy link
Collaborator

cmichi commented Apr 4, 2023

The Idea

I would love to see code testing of our Rust code examples. This should be analog to how it works for Rust doc tests.

Reminder: In Rust comments, code snippets can be included like this:

/// ```
/// # <ink_ir::ItemImpl as TryFrom<syn::ItemImpl>>::try_from(syn::parse_quote! {
/// impl MyStorage {
///     #[ink(constructor)]
///     pub fn my_constructor() -> Self {
///         // constructor implementation
///         unimplemented!()
///     }
/// }
/// # }).unwrap();
/// ```

In the HTML-generated documentation the lines prefixed with # won't show up. But if you execute cargo test --doc the entire code snippet will be compiled, including the # prefixed lines.

We need something along those lines for use.ink.

ToDo

docusaurus uses prism.js for rendering code into HTML.

  • Check if that tool supports hiding lines. I had briefly checked and didn't find anything. Might have overlooked it though.
  • If it does not, create a PR for it to add this feature.

Follow-ups

This is not part of this ticket, but once we have the hide-lines feature for code we can:

  • Ask Parity's OpsTooling to create a tool that extracts this code and compiles it.
  • Integrate this tool into our CI.
  • Add surrounding code to existing code snippets, so that they compile.
@cmichi cmichi added enhancement New feature or request help wanted Extra attention is needed labels Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant