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 generated documentation for Unix devices #824

Closed
stgraber opened this issue May 3, 2024 · 5 comments
Closed

Add generated documentation for Unix devices #824

stgraber opened this issue May 3, 2024 · 5 comments
Assignees
Labels
Documentation Documentation needs updating Easy Good for new contributors
Milestone

Comments

@stgraber
Copy link
Member

stgraber commented May 3, 2024

Incus is slowly moving to automatically generated documentation for its configuration keys.

This can be done through the gendoc:generate type comments in the code, followed by running make update-metadata and consumption in the documentation through {include} ../config-option.txt.

This issue is for the keys defined in doc/reference/device_unix_block.md, doc/reference/device_unix_char.md, doc/reference/device_unix_hotplug.md to be moved to code in internal/server/device/unix_common.go and internal/server/device/unix_hotplug.go.

@stgraber stgraber added Documentation Documentation needs updating Easy Good for new contributors labels May 3, 2024
@stgraber stgraber added this to the soon milestone May 3, 2024
@milaiwi
Copy link
Contributor

milaiwi commented May 3, 2024

Can I get this assigned? I'm thinking we essentially have to add gendoc:generate comments to the structs defined in the *.go files that include information outlined in the *.md (Key, Type, Default Description). It would just be three different commits, something like:

internal/device/unix_hotplug.go: Added gendoc:generate comments for automatic documentation generation.

@stgraber
Copy link
Member Author

stgraber commented May 3, 2024

Assigned it to you, and yeah, that's right. We usually put the gendoc:generate comment just above where we have the config key validation logic validate.IsXYZ so that anyone modifying the validation logic will see the documentation and update it at the same time.

@milaiwi
Copy link
Contributor

milaiwi commented May 3, 2024

for gendoc:generate, what would the parameters for something like this be? I tried to find documentation for this but couldn't. I'm thinking something like gendoc:generate(entity=instance, group=miscallaneous, key=unix_hotplug_devices.gid). So if we're generating for something like this:

 Key         | Type      | Default           | Description
 :--         | :--       | :--               | :--
 `gid`       | int       | `0`               | GID of the device owner in the instance

We'd write something like:

      // gendoc:generate(entity=instance, group=miscallaneous, key=unix_hotplug_devices.gid)
      //
      // ---
      //  key: gid
      //  type: int
      //  default: 0
      //  shortdesc: GID of the device owner in the instance
      "unix_hotplug_devices.gid": validate.Optional(validate.IsInt)

@stgraber
Copy link
Member Author

stgraber commented May 3, 2024

Maybe:

  • entity: instance_device
  • group: unix-hotplug
  • key: gid

@milaiwi
Copy link
Contributor

milaiwi commented May 5, 2024

I made a pull request and tested the documentation on localhost. I've ran into issues with passing the make doc-spellcheck test and get this error:

The HTML pages are in doc/html.
. doc/.sphinx/venv/bin/activate ; python3 -m pyspelling -c doc/.sphinx/spellingcheck.yaml
['aspell', '--lang', 'en', '--encoding', 'utf-8', 'create', 'master', '/home/ubuntu/incus/doc/.sphinx/.wordlist.dic']
Current wordlist: 'doc/.wordlist.txt'
Problem compiling dictionary. Check the binary path and options.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__main__.py", line 97, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__main__.py", line 37, in main
    return run(
           ^^^^
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__main__.py", line 64, in run
    for results in spellcheck(
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__init__.py", line 742, in spellcheck
    for result in spelltask.run_task(task, source_patterns=sources):
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__init__.py", line 657, in run_task
    self.personal_dict = self.spellchecker.setup_dictionary(self.task, self.binary, self.verbose)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__init__.py", line 273, in setup_dictionary
    cls.compile_dictionary(
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/__init__.py", line 315, in compile_dictionary
    util.call(
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/util/__init__.py", line 97, in call
    process = get_process(cmd)
              ^^^^^^^^^^^^^^^^
  File "/home/ubuntu/incus/doc/.sphinx/venv/lib/python3.12/site-packages/pyspelling/util/__init__.py", line 66, in get_process
    process = subprocess.Popen(
              ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'aspell'
make: *** [Makefile:175: doc-spellcheck] Error 1

I've been having trouble tracing the issue, though.

stgraber added a commit that referenced this issue May 6, 2024
Added generated documentation for Unix devices #824
@stgraber stgraber closed this as completed May 6, 2024
@stgraber stgraber modified the milestones: soon, incus-6.2 May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation needs updating Easy Good for new contributors
Development

No branches or pull requests

2 participants