Skip to content

Move jets documentation inside compiler#251

Open
gerau wants to merge 6 commits intoBlockstreamResearch:masterfrom
distributed-lab:lsp/jets-docs
Open

Move jets documentation inside compiler#251
gerau wants to merge 6 commits intoBlockstreamResearch:masterfrom
distributed-lab:lsp/jets-docs

Conversation

@gerau
Copy link
Copy Markdown
Contributor

@gerau gerau commented Mar 23, 2026

Right now we have 3 different sources in which we are getting information about Jet: LSP, codegen crate (which would generate modules for SimplicityHL-as-Rust) and simplicity-lang-org.

This PR moves Jet documentation from codegen crate to SimplicityHL compiler, which is gated behind docs feature. Also, I had added codegen executable to be distributed alongside with simplicityhl crate, also gated behind docs feature. This executable supports old behavior of generating modules, and also extends to generating JSON file with jet documentation (see BlockstreamResearch/simplicity-lang-org#42 for more context). There are launch instructions in codegen/README.md.

In future, I would like to add JetInfo as a trait for Jet, after this issue resolved, so it could also load in runtime jets documentation.

@gerau gerau requested a review from delta1 as a code owner March 23, 2026 16:27
@gerau gerau changed the title Jet documentation inside compiler Move jets documentation inside compiler Mar 23, 2026
Copy link
Copy Markdown
Contributor

@stringhandler stringhandler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 99425de

Some minor comments

src/docs/jet.rs Outdated
Elements::Some32 => "Check if a 32-bit value is nonzero.",
Elements::Some64 => "Check if a 64-bit value is nonzero.",
Elements::Verify => r#"Assert that a bit is true.
Elements::Verify => r#"**Deprecated; do not use.** Assert that a bit is true.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is deprecated?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually doesn't exist anymore. I'm not sure of the history of this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does exist in low-level Simplicity but there is some reason that I don't quite understand that it's not mapped into SimplicityHL.

Copy link
Copy Markdown
Collaborator

@KyrylR KyrylR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify and CheckSigVerify are uncategorized, so docs are not generated, is it Ok?

- "haskell_name" -- The name of the jet used in the Haskell and Rust code.
- "simplicityhl_name" -- The name of the jet as it is used in SimplicityHL.
- "section" -- The category to which the jet belongs.
- "input_type" -- The input type represented as an `AliasedType` in SimplicityHL.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually a Vector:

input_type: simplicityhl::jet::source_type(jet)
    .iter()
    .map(|ty| ty.to_string())
    .collect::<Vec<_>>()
    .join(", "),

@gerau
Copy link
Copy Markdown
Contributor Author

gerau commented Mar 25, 2026

Verify and CheckSigVerify are uncategorized, so docs are not generated, is it Ok?

I'm not sure what to do with them, because we cannot call this jets from SimplicityHL code (source:

SimplicityHL/src/ast.rs

Lines 1297 to 1299 in 682d829

Ok(Elements::CheckSigVerify | Elements::Verify) | Err(_) => {
Err(Error::JetDoesNotExist(name.clone())).with_span(from)
}
). Verify jet is actually the same as assert! (
CallName::Assert => {
let jet = ProgNode::jet(scope.ctx(), Elements::Verify);
scope.with_debug_symbol(args, &jet, self)
}
). We could mark them as "not available in SimplicityHL" instead of deprecated message as an option.

@gerau gerau force-pushed the lsp/jets-docs branch 2 times, most recently from b49022b to 653c4d7 Compare March 26, 2026 14:01
@gerau
Copy link
Copy Markdown
Contributor Author

gerau commented Mar 26, 2026

Verify and CheckSigVerify are uncategorized, so docs are not generated, is it Ok?

I think it is fine, because these jets are only accessible from Simplicity, and not SimplicityHL, but I would also like to hear @schoen's opinion about that as well.

gerau added 5 commits March 26, 2026 17:58
This moves jet documentation out of `codegen` crate into `SimplicityHL`,
and gates it behind `documentation` feature.
This sync changes from `simplicity-lang-org` and fixes several typos.
Also adds `Verify` and `CheckSigVerify` to categories.
This makes `codegen` binary work with two subcommands:
- `modules`: generates rust modules, as previous implementation (with
  optional --out-dir flag to define folder in which code would generate)
- `docs`: generates json file with jet documentation.
@gerau gerau force-pushed the lsp/jets-docs branch 2 times, most recently from b09c61b to d00ae35 Compare March 26, 2026 16:02
@KyrylR
Copy link
Copy Markdown
Collaborator

KyrylR commented Mar 27, 2026

Also could you align with @schoen
Here for example: https://github.com/BlockstreamResearch/simplicity-lang-org/blob/28c67437c6cef3b111339443293a672d237d72a3/jets.md.py#L45 it expects different structure of produced JSON

So if this PR is merged this should be fixed as well, as this a breaking change we should document it

@schoen
Copy link
Copy Markdown
Contributor

schoen commented Mar 27, 2026

@KyrylR I have already spoken to @gerau about the structure of the JSON and I'm not concerned about that problem (I plan to update the Python script). It is true that this is a breaking change but currently that Python script doesn't run automatically, only manually.

Related:

BlockstreamResearch/simplicity-lang-org#42

Basically, I'll have to do several things to take advantage of the work in this PR for the website, and I'm aware of the need to do them.

@schoen
Copy link
Copy Markdown
Contributor

schoen commented Mar 27, 2026

Verify and CheckSigVerify are uncategorized, so docs are not generated, is it Ok?

I think it is fine, because these jets are only accessible from Simplicity, and not SimplicityHL, but I would also like to hear @schoen's opinion about that as well.

I'd like to learn more about the history of the underlying issue, but from the point of SimplicityHL documentation, I think we should not generate docs for these jets because we can't call them from SimplicityHL, so from the point of view of SimplicityHL developers right now, it's essentially as if they don't exist in the language.

This might be a minor point suggesting that there could someday be separate documentation generated for Simplicity and for SimplicityHL, but I don't think we need to worry about that right now.

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.

4 participants