devenv icon indicating copy to clipboard operation
devenv copied to clipboard

doc: implement meta.doc

Open sandydoo opened this issue 1 year ago • 7 comments

@k3yss

This is basically what NixOS does. The meta attribute is allowed by the module system, but not defined by default, so we can hijack it for our needs. Every module now has a meta.doc field that can be populated.

I tried doing a submodule for languages, but there's some sort of error about nested options that needs investigating.

languages = lib.mkOption {
  type = types.attrsOf (types.submodule ({...}: {
    freeformType = types.attrsOf (types.submodule ({...}: {
      imports = [ ./doc.nix ];
    }));
  }));
};

The tricky bit is that we define the nav manually in mkdocs.yml. I'm not sure how to tell it to pick up all files within a directory. We might need to write a small plugin.

sandydoo avatar May 29 '24 17:05 sandydoo

It might be more convenient to write docs in a separate markdown file and then point meta.doc to it.

Technically, we don't really need this machinery right now. If we just want to add language guides, then those markdown files can live in docs. 🤷

sandydoo avatar May 29 '24 17:05 sandydoo

I am also in favor of writing the docs in separate markdown file. I think it's better if we generate the docs dynamically, as we do now; otherwise, we won't have any connection between the .nix files and .md files, which could make the codebase difficult to navigate for future contributors.

Also how would we include the option references that we currently employ with this format as that too will be dynamically generated?

k3yss avatar May 29 '24 17:05 k3yss

Deploying devenv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 23e0e6c
Status: ✅  Deploy successful!
Preview URL: https://497e0677.devenv.pages.dev
Branch Preview URL: https://add-doc-meta.devenv.pages.dev

View logs

I think it's better if we generate the docs dynamically, as we do now; otherwise, we won't have any connection between the .nix files and .md files

Well, we generate the reference docs (and some other bits), but everything else, like guides, lives in /docs. That's why I'm curious what the goal is with this setup. If we make meta.doc point to a markdown file, then it can live next to the nix module it describes. But we don't really need nix to find those files and copy them over to /docs.

Also how would we include the option references that we currently employ with this format as that too will be dynamically generated?

The reference options are generated separately in devenv-generate-doc-options. This doesn't affect that. You can reference options in the meta.doc if you need to though (see diff).

sandydoo avatar May 29 '24 18:05 sandydoo

But we don't really need nix to find those files and copy them over to /docs.

I think if the docs are stored in the /docs directory and we point to it using meta.doc we will be fine. But we should implement a conditional to only render the docs if it is referenced via meta.doc, else throw an error for the doc being not referenced or not render it on the website.

k3yss avatar May 29 '24 19:05 k3yss

I wonder if we get any benefit from this over just docs/languages/python.dm?

domenkozar avatar Jun 09 '24 09:06 domenkozar

I wonder if we get any benefit from this over just docs/languages/python.dm?

If we just want to add language guides, then those markdown files can live in docs. 🤷

Yeah, that's what I'm saying.

sandydoo avatar Jun 10 '24 15:06 sandydoo

Should we close this @sandydoo

k3yss avatar Aug 16 '24 16:08 k3yss