Skip to content

[Extension] Extract and test Compliant and Non-compliant code blocks #91

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

x0rw
Copy link
Contributor

@x0rw x0rw commented May 25, 2025

Extract code blocks from .rst files and create a global Rust test file (generated.rs) to check them all together using
rustc --test --edition=2021 exts/rust-code-runner/generated.rs under the hood.

Features:

  • marker comments to hide specific code from being rendered in html:
      .. code-block:: rust

        // HIDDEN START
        use std::fs;
        use std::io::{self, Read};
        // HIDDEN END 

anything between // HIDDEN START and // HIDDEN END will not be rendered but will still be included for compilation in the generated test file.

  • This extension is not tied to the other 'needs' extension so it can be used in other projects that require similar features.
  • A set of functions that parse rustc --error-format=json output and extract minimal error information.

Tasks:

  • Write unit tests -- this mostly uses regex(scary) for extracting code blocks.
  • Comments
  • Refactor
  • Feature-gate running code, for CI integration.

How to test:

Run: ./make.py -c --offline it will notify you in case there is any issue in any code block,
also check exts/rust-code-runner/generated.rs after doing so.

(Not rebased yet)
Resolves #80

Copy link

netlify bot commented May 25, 2025

Deploy Preview for scrc-coding-guidelines ready!

Name Link
🔨 Latest commit e5df07c
🔍 Latest deploy log https://app.netlify.com/projects/scrc-coding-guidelines/deploys/6833945f0e72e80007d7a704
😎 Deploy Preview https://deploy-preview-91--scrc-coding-guidelines.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@x0rw x0rw marked this pull request as draft May 25, 2025 22:02
@PLeVasseur
Copy link
Collaborator

Hey @x0rw -- thanks for starting on this!

Could I ask for your reason for choosing the 2021 edition instead of the newer 2024 edition?

@x0rw
Copy link
Contributor Author

x0rw commented May 26, 2025

Could I ask for your reason for choosing the 2021 edition instead of the newer 2024 edition?

I just went with 2021 out of habit.

@PLeVasseur
Copy link
Collaborator

Could I ask for your reason for choosing the 2021 edition instead of the newer 2024 edition?

I just went with 2021 out of habit.

Could we update to the 2024 edition then?

@PLeVasseur
Copy link
Collaborator

Hey @x0rw -- wanted to check in to see if this is a work in progress or ready for review

@x0rw
Copy link
Contributor Author

x0rw commented Jun 7, 2025

It’s still in progress. I need to write some tests for it (haven’t found the time yet) because it can easily fail and cause false alerts, I guess.

@PLeVasseur
Copy link
Collaborator

Okay, thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add infrastructure for how to extract and test compliant and non-compliant code
2 participants