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 nox config to automate building docs #54

Closed
gotmax23 opened this issue Jul 5, 2023 · 11 comments
Closed

Add nox config to automate building docs #54

gotmax23 opened this issue Jul 5, 2023 · 11 comments
Labels
doc builds Relates to building the documentation

Comments

@gotmax23
Copy link
Collaborator

gotmax23 commented Jul 5, 2023

It would be nice to have a nox or tox configuration to clone ansible-core, install the necessary build dependencies in a managed virtualenv, and build docs. This improves the contributor experience, as they can run one command instead of four (clone core, create venv, install deps, run Makefile) to build the docs.

nox and tox both preform similar purposes. They allow running different jobs and manage each job's dependencies in a separate virtualenv. nox has its config in Python and tox has a domain-specific INI-like configuration format. I personally prefer nox, and we successfully adopted it in the 5 antsibull projects, but other projects in the ecosystem use tox.

/cc @mattclay

@gotmax23 gotmax23 added the doc builds Relates to building the documentation label Jul 5, 2023
@gotmax23
Copy link
Collaborator Author

I have have a simple noxfile locally that just sets up a venv and calls make:

from __future__ import annotations

import nox


@nox.session
def make(session: nox.Session) -> None:
    session.install("-r", "docs/docsite/requirements.txt")
    session.run("make", "-C", "docs/docsite/", *session.posargs, external=True)

I'm not sure that this is the best solution (we might want to create separate nox sessions to correspond to Makefile targets or move things out of the Makefile), but nox -- coredocs works for me for now.

@webknjaz
Copy link
Member

Since you asked for feedback, I'll say that using nox is probably a better fit for a docs project, even though I tend to use tox myself. Hynek recently mentioned that nox doesn't do parallelism well (https://hynek.me/articles/turbo-charge-tox/) but it's probably unnecessary here. I'll let @oraNod make that decision.

@oraNod
Copy link
Contributor

oraNod commented Jul 13, 2023

+1 to nox. I'm sure there are other pros and cons to consider but my preference is for Python over ini. I feel like there would be some advantages there when/if we do move things out of the Makefile.

@webknjaz
Copy link
Member

when/if we do move things out of the Makefile.

I'd argue that it's supposed to replace makefile and removing it should be a part of the PR that integrates nox. If noxfile is added but not integrated, it won't be tested and much less people may end up using it.

@felixfontein
Copy link
Collaborator

I would probably leave a Makefile that translates the existing Makefile targets to nox commands (at least for a while). That way folks can still use their make xxx commands (and see to which nox -e ... commands these translate).

@gotmax23
Copy link
Collaborator Author

Are we defining the scope of this as

  1. completely replacing the current Makefile with nox and re-implementing the whole thing in nox's Python syntax

or

  1. just adding a noxfile that calls the existing Makefile targets and has extra sessions to generate constraints with pip-compile (Updating doc build requirements #108) and run linters and such

?

@webknjaz
Copy link
Member

Please, don't call make from nox. That defeats the entire purpose of it being the main workflow too.l.

@samccann
Copy link
Contributor

I'm +1 for simplifying the docs build. I forget the core clone..ahem... regularly. I don't know enough about make vs nox/tox to have an opinion.

gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Aug 15, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

Relates: ansible#54
gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Aug 21, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

Relates: ansible#54
gotmax23 added a commit that referenced this issue Aug 21, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

Relates: #54
gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Aug 22, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

Relates: ansible#54
(cherry picked from commit 40285f8)
@samccann
Copy link
Contributor

As part of this change, is it possible to move the ability to make docs (whatever the new command is) into the root dir instead of having to cd to docs/docsite every time? Historically it was this way only because we were part of ansible/ansible and had separate makes from their project make so to speak.

..I'm lazy and tired of the extra step :-)

@gotmax23
Copy link
Collaborator Author

@samccann, yes that's the plan. You can currently run make -C docs/docsite as one command, but that's still not so nice.

gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Aug 27, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

Relates: ansible#54
(cherry picked from commit 40285f8)
gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Aug 27, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

(cherry picked from commit 40285f8)

Relates: ansible#54
@samccann samccann moved this from 🆕 Triage to 🏗 In progress in Ansible Documentation Oct 17, 2023
gotmax23 added a commit to gotmax23/ansible-documentation that referenced this issue Oct 22, 2023
Currently, this only lints the noxfile itself and the issue labeler
script.
We can expand the noxfile to build docs and lint other new files in
hacking.

(cherry picked from commit 40285f8)

Relates: ansible#54
@oraNod
Copy link
Contributor

oraNod commented Dec 5, 2023

Thanks for all the work here @gotmax23 I think we can close this out now that we have nox sessions for all ci tooling as well as make. We can create follow on issues as needed to capture the work of porting make syntax to nox. As I mentioned elsewhere I hope nox tooling will also allow us to tackle break the package docs build into separate stages. It might be wishful thinking on my part but I think that approach combined with some Sphinx optimizations is the way forward.

@oraNod oraNod closed this as completed Dec 5, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Ansible Documentation Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc builds Relates to building the documentation
Projects
Status: Done
Development

No branches or pull requests

5 participants