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

Add documentation to public functions #14

Open
vlinkz opened this issue Sep 28, 2022 · 7 comments
Open

Add documentation to public functions #14

vlinkz opened this issue Sep 28, 2022 · 7 comments
Assignees

Comments

@vlinkz
Copy link
Collaborator

vlinkz commented Sep 28, 2022

Currently, none of the public functions have proper documentation comments, so the generated docs are empty.
See: https://docs.rs/nix-editor/latest/nix_editor/

Documentation is needed describing what each function does, as well as providing some examples.
Getting started: https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html

@Adelakin-Adewumi
Copy link

I will love to work on this documentation. Kindly assign it to me.

@vlinkz
Copy link
Collaborator Author

vlinkz commented Sep 30, 2022

Sounds great! I've assigned you the issue. Since the code is a bit messy I'd say the most important things to document at the moment are.

From read.rs:

From write.rs:

From parse.rs

A lot of it is pretty confusing, so please let me know if you have any questions! Also don't feel obligated to do all since there is a lot and the code is very convoluted. A lot of the code ties heavily in with the rnix crate: (https://docs.rs/rnix/0.10.2/rnix/), so most non-standard rust types are coming from there

@Adelakin-Adewumi
Copy link

Sounds great! I've assigned you the issue. Since the code is a bit messy I'd say the most important things to document at the moment are.

From read.rs:

From write.rs:

From parse.rs

A lot of it is pretty confusing, so please let me know if you have any questions! Also don't feel obligated to do all since there is a lot and the code is very convoluted. A lot of the code ties heavily in with the rnix crate: (https://docs.rs/rnix/0.10.2/rnix/), so most non-standard rust types are coming from there

Okay, I'd let you know if I have any question. I want to go through it. Thank you

@Adelakin-Adewumi
Copy link

Adelakin-Adewumi commented Sep 30, 2022 via email

@vlinkz
Copy link
Collaborator Author

vlinkz commented Sep 30, 2022

Of course!

Basically, this project is a tool called nix-editor which can be used to modify .nix files programmatically while maintaining valid syntax. .nix files are primarily used by NixOS and the Nix package manager to declaratively build packages and configurations (see: https://nixos.org/). The primary usage of this tool is so that other programs can modify .nix files imperatively, some examples of tools using this are Nix Software Center and NixOS Configuration Editor. The tool also has a command line utility so that even programs not written in rust can take advantage of the functionality.

Here's a quick example of how it could be used, say we have a file default.nix containing the following:

{
  value1 = "Hello";
}

If we want to add another value to this attribute set, we could use nix-editor as follows:

nix-editor default.nix  value2 -v '"world!"' -o default.nix

Now the file default.nix would contain

{
  value1 = "Hello";
  value2 = "world!";
}

While this tool does have a command line help screen, since there is no documentation for the backend function, trying to implement it into other rust programs can be difficult at the moment. The functions don't need very long descriptions, just a simple description or sentence should do, for example:
pub fn readvalue

/// Returns the value of the query from the given input string of `.nix` file text `f` and query `query`, 
pub fn readvalue(f: &str, query: &str) -> Result<String, ReadError> {

@Adelakin-Adewumi
Copy link

Of course!

Basically, this project is a tool called nix-editor which can be used to modify .nix files programmatically while maintaining valid syntax. .nix files are primarily used by NixOS and the Nix package manager to declaratively build packages and configurations (see: https://nixos.org/). The primary usage of this tool is so that other programs can modify .nix files imperatively, some examples of tools using this are Nix Software Center and NixOS Configuration Editor. The tool also has a command line utility so that even programs not written in rust can take advantage of the functionality.

Here's a quick example of how it could be used, say we have a file default.nix containing the following:

{
  value1 = "Hello";
}

If we want to add another value to this attribute set, we could use nix-editor as follows:

nix-editor default.nix  value2 -v '"world!"' -o default.nix

Now the file default.nix would contain

{
  value1 = "Hello";
  value2 = "world!";
}

While this tool does have a command line help screen, since there is no documentation for the backend function, trying to implement it into other rust programs can be difficult at the moment. The functions don't need very long descriptions, just a simple description or sentence should do, for example: pub fn readvalue

/// Returns the value of the query from the given input string of `.nix` file text `f` and query `query`, 
pub fn readvalue(f: &str, query: &str) -> Result<String, ReadError> {

okay, thank you. I will do a PR, i hope you will like it and merge it.

@axelkar
Copy link

axelkar commented Dec 14, 2024

Hi! Any progress on this?

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

No branches or pull requests

3 participants