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

generate docs for api.oxen.io #2155

Open
majestrate opened this issue Apr 8, 2023 · 9 comments
Open

generate docs for api.oxen.io #2155

majestrate opened this issue Apr 8, 2023 · 9 comments
Labels
documentation related to documentation good first issue Good for newcomers

Comments

@majestrate
Copy link
Contributor

we should make a util that will spit out markdown for api.oxen.io for lokinet's config options and the zmq rpc api.

@majestrate majestrate added good first issue Good for newcomers documentation related to documentation labels Apr 8, 2023
@majestrate
Copy link
Contributor Author

we have programmatic comments in our config gen as well as other hints about usage, thinking we make an executable that:

  • spits out a list of all config sections
  • given a section, print a high level description of the section
  • given a section list all option names
  • given a section and option print out markdown text for documentation on it.

then you can do something like:

for sect in $( docgen sections ) ; do
  for opt in $( docgen opts $sect ) ; do
    docgen markdown $sect $opt 
  done
done > lokinet.md

@majestrate
Copy link
Contributor Author

or... it could just spit out all the docs

@N-NeelPatel
Copy link

@majestrate - can I work on this to generate docs using commands?

@majestrate
Copy link
Contributor Author

go ahead

@N-NeelPatel
Copy link

N-NeelPatel commented May 23, 2023

@majestrate - I created a shell script according to the points you mentioned above. Do you think it is workable? let me know what you think.

#!/bin/bash

config_file="path/to/config_file.conf"  # Replace with the actual path to your config file

list_sections() {
    grep -E "^\[[^\]]+\]" "$config_file" | sed 's/\[\(.*\)\]/\1/'
}

describe_section() {
    section="$1"
    description=$(grep -A 1 -e "^\[$section\]" "$config_file" | tail -n 1 | sed 's/# *//')
    echo "$description"
}

list_options() {
    section="$1"
    awk -F "=" "/^\[$section\]/,/^(\[.*\]|$)/ { if (\$1 ~ /^[a-zA-Z_][a-zA-Z0-9_]*$/) print \$1 }" "$config_file"
}

generate_documentation() {
    section="$1"
    option="$2"
    documentation=$(grep -A 1 -e "^\[$section\]" "$config_file" | grep -A 1 -e "^[[:space:]]*$option[[:space:]]*=")
    echo "$documentation"
}

for sect in $(list_sections); do
    for opt in $(list_options "$sect"); do
        generate_documentation "$sect" "$opt"
    done
done > lokinet.md

@majestrate
Copy link
Contributor Author

majestrate commented May 23, 2023 via email

@majestrate
Copy link
Contributor Author

nevermind, we have not merged in the rpc refactor yet so that would need to be figure out first... hmmm.

@N-NeelPatel
Copy link

So this won't be done until rpc refactor is merged?

@majestrate
Copy link
Contributor Author

yes correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation related to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants