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

sharable documentation on the fields and meanings #98

Open
daym opened this issue Jul 22, 2023 · 3 comments
Open

sharable documentation on the fields and meanings #98

daym opened this issue Jul 22, 2023 · 3 comments
Assignees

Comments

@daym
Copy link
Collaborator

daym commented Jul 22, 2023

hanetzer asked:

any kind of sharable documentation on the fields and meanings and such?

@daym daym changed the title any kind of sharable documentation on the fields and meanings and such? sharable documentation on the JSON fields and meanings Jul 22, 2023
@daym daym changed the title sharable documentation on the JSON fields and meanings sharable documentation on the fields and meanings Jul 22, 2023
@daym
Copy link
Collaborator Author

daym commented Jul 22, 2023

Yeah, we could add some more documentation on what the entire structs mean and what the PSP is doing with them overall.

As for fields, there are docstrings on a lot of fields--and using cargo doc, you should see them (the documents created by cargo doc describe the public interface). These docstrings are also in the JSON schema generated by the schemars feature, and of course are in the source code (mostly in src/ondisk.rs ).

@hanetzer
Copy link

hanetzer commented Jul 22, 2023

nice, yeah. As much as I appreciate source, I'm not a native rust speaker, so making heads and tails of it is tricky for me.
where do the json schemas end up? and what filetype is that?

@daym
Copy link
Collaborator Author

daym commented Aug 17, 2023

You can make it dump the schema via this program:

use std::error::Error;
use std::fs::File;
use std::io::BufWriter;
use std::io::Write;
use schemars::schema_for;
use amd_apcb::Apcb;

fn main() -> Result<(), Box<dyn Error>> {
    let schema = schema_for!(Apcb);
    let file = File::create("/tmp/Q.json")?;
    let mut writer = BufWriter::new(file);
    serde_json::to_writer(&mut writer, &schema)?;
    writer.flush()?;
    Ok(())
}

The result is a json schema (in json). You can use any JSON schema aware editor to edit your config files. I use IntelliJ IDEA. You can associate the schema in the editor at the bottom statusbar. If you use emacs, there is also https://emacs-lsp.github.io/lsp-mode/page/lsp-json/ . For vi, there is https://github.com/Quramy/vison .

To be clear, you open up the config you already have in the editor and then you associate a schema with that file in the editor program.

image

image

image

There's a program to generate the schema out of the box (and the entire flash editing), but it's in review.

@daym daym self-assigned this Aug 17, 2023
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

No branches or pull requests

2 participants