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 API docs with Doxygen #7896

Merged
merged 1 commit into from
Mar 10, 2023
Merged

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Feb 23, 2023

Motivation

The motivation is as stated in issue #7814: even though the the C++ API is internal and unstable, people still want it to be well documented for sake of learning, code review, and other purposes that aren't predicated on it being stable.

Per the brief discussion with the Nix team it is:

  1. Not built by default as part of the main derivation
  2. Can be built in the dev shell
  3. Will be built by CI

Basically, it is done analogous to the coverage CI job, which is similarly a "bonus feature".

Context

Fixes #7814

Many things were modeled off of #7901. Thanks @roberth!

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

@abathur
Copy link
Member

abathur commented Feb 23, 2023

This FWIW probably isn't relevant for the use case here, but since nix already leans on sqlite I figure I should mention that doxygen has an optional/experimental sqlite output :)

@Ericson2314
Copy link
Member Author

If that is useful for e.g. interactive IDE features, it might indeed be relevant. We are, after all, targeting people that want to work on Nix itself, since this is not part of Nix's public interface.

@abathur
Copy link
Member

abathur commented Feb 24, 2023

I haven't really looked into doxygen-output-consuming ide tooling.

It could, but I suspect if it already exists it's probably built on the xml output (it's existed longer, it's default/~stable).

But it does make it a little easier to build some kinds of tooling.

@roberth
Copy link
Member

roberth commented Feb 26, 2023

A devdoc output would be nice, but an independent derivation should be even nicer, although I don't think we can really pull that off yet without overcomplicating things.

@Ericson2314
Copy link
Member Author

Yeah I would do that after your --enable-tests PR, @roberth :)

@fricklerhandwerk fricklerhandwerk added documentation contributor-experience Developer experience for Nix contributors labels Mar 3, 2023
@fricklerhandwerk
Copy link
Contributor

Triaged in the Nix team meeting:

We absolutely want this, but don't include it in the manual to avoid making the impression this is somehow a public interface. It's just to improve developer experience.

Decision: Please add a it as a new makefile target and separate derivation output.

Complete discussion
  • @tomberek: inspecting structural changes visually will be much easier than reading header files
  • @Ericson2314: there will also be more information for the reviewer
  • @fricklerhandwerk: we already agreed we want this
    • @tomberek: the open issue was how to make unmistakably clear that this is not a public interface
      • could simply add a different make target or derivation output, bt not include it in the manual
  • @Ericson2314: a lot of comments will have to be updated to follow the doxygen convention, this may be a good beginner project
    • @edolstra: wouldn't want beginners document code they don't understand
      • the only thing worse than missing documentation is incorrect documentation
    • @fricklerhandwerk: disagree on the premise; had multiple pairing and mob sessions digging through the code to understand what it does, and it produced sensible documentation
      • it helps a lot with onboarding beginners and spurs a discussion with maintainers
    • @edolstra: PRs are fine, but they should absolutely not be merged without review by someone knowledgeable with the code
      • the documentation should be authoritatively correct
      • @fricklerhandwerk: yes, obviously

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-03-nix-team-meeting-minutes-37/25998/1

@Ericson2314
Copy link
Member Author

OK I think this is ready now!

@fricklerhandwerk
Copy link
Contributor

Example class diagram rendered:

structnix_1_1Installable

@fricklerhandwerk
Copy link
Contributor

Discussed in Nix team meeting:

  • @edolstra: we want API docs, but not sure about doxygen specifically (it's atrociously ugly)
    • can go for it if no better alternatives available, don't know any
    • the real issue is that our source code is not suitable to provide useful doxygen output
      • needs nice class hierarchies, and we don't have that
      • everything ends up in the giant nix namespace, and that's not useful organisation
      • may incenetivise refactorings though in order to get closer to that, e.g. of the util functions
  • @Ericson2314: the subject came up related to the parts with more inheritance structure, in order to provide better overview visually
    • it's already delivering value there
  • @edolstra: why is the doxygen config 2700 LOC?
  • @edolstra: should add a Hydra build result so the docs can be browsed from Hydra
  • Sphinx has some support, but it turns out it uses Doxygen too!
  • agreement: idea approved, fix the config file

@roberth roberth assigned edolstra and unassigned tomberek and fricklerhandwerk Mar 6, 2023
mk/disable-api-docs.mk Outdated Show resolved Hide resolved
@roberth
Copy link
Member

roberth commented Mar 6, 2023

  • needs nice class hierarchies, and we don't have that

We do. These docs are really helpful for getting an overview of how CLI commands are composed through mix-ins.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make clear that it's our internal api.

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
doc/api/local.mk Outdated Show resolved Hide resolved
@Ericson2314 Ericson2314 force-pushed the doxygen branch 2 times, most recently from 2048984 to f4ead8d Compare March 6, 2023 15:44
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-06-nix-team-meeting-minutes-38/26056/1

@Ericson2314
Copy link
Member Author

OK @edolstra, I think I fixed everything brought up in the meeting. It's all yours now!

@Ericson2314
Copy link
Member Author

Oops I forgot to note hydra build products as discussed in the meeting. This is done now.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good start.

doc/internal-api/local.mk Show resolved Hide resolved
doc/internal-api/local.mk Show resolved Hide resolved
The motivation is as stated in issue NixOS#7814: even though the the C++ API
is internal and unstable, people still want it to be well documented for
sake of learning, code review, and other purposes that aren't predicated
on it being stable.

Fixes NixOS#7814

Co-authored-by: Robert Hensing <[email protected]>
@Ericson2314 Ericson2314 enabled auto-merge March 10, 2023 17:52
@Ericson2314 Ericson2314 merged commit 208c855 into NixOS:master Mar 10, 2023
@Ericson2314 Ericson2314 deleted the doxygen branch March 10, 2023 18:43
@roberth roberth mentioned this pull request Mar 16, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/this-month-in-nix-docs-1-march-2023/26913/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor-experience Developer experience for Nix contributors documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

API docs
7 participants