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

lxddoc: Add a readthedoc pre-build hook to build and generate codebase doc #12043

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

gabrielmougard
Copy link
Contributor

@gabrielmougard gabrielmougard commented Jul 19, 2023

@ru-fu Now lxd-doc can be built from source and executed entirely from the conf.py file which means that we no longer have to use the makefile and it should directly integrates with the readthedoc pipeline.

@github-actions github-actions bot added the Documentation Documentation needs updating label Jul 19, 2023
@gabrielmougard gabrielmougard marked this pull request as draft July 19, 2023 12:37
@gabrielmougard gabrielmougard force-pushed the feat/readthedoc branch 3 times, most recently from f6b3996 to 7a06337 Compare July 19, 2023 12:58
@gabrielmougard gabrielmougard marked this pull request as ready for review July 19, 2023 13:01
@gabrielmougard gabrielmougard force-pushed the feat/readthedoc branch 2 times, most recently from 97be63d to b7f8755 Compare July 19, 2023 14:05
@tomponline tomponline requested a review from ru-fu July 19, 2023 14:07
@gabrielmougard gabrielmougard force-pushed the feat/readthedoc branch 2 times, most recently from bb03740 to 221b98b Compare July 19, 2023 14:18
@ru-fu
Copy link
Contributor

ru-fu commented Jul 19, 2023

I tested it locally now, and I think it works - but we should remove it from the Makefile. I'm actually not sure when the generation happens now. ;)

Also, I tried including our example in the docs now, with the following markup:

```{include} config_options.txt
    :start-after: <!-- config group cluster start -->
    :end-before: <!-- config group cluster end -->
```

This gives an error though, because the - (default value for the second option) must be enclosed in quotes.
This isn't related to this PR, but must also be fixed.

@gabrielmougard
Copy link
Contributor Author

@ru-fu you're right, the lxd-doc tool is called twice now. I'll remove it from the make doc target. But maybe we can keep a separate makefile target to call lxd-doc without generating the readthedoc pages (maybe it could be of some use for "preview" purposes)

@ru-fu
Copy link
Contributor

ru-fu commented Jul 20, 2023

@ru-fu you're right, the lxd-doc tool is called twice now. I'll remove it from the make doc target. But maybe we can keep a separate makefile target to call lxd-doc without generating the readthedoc pages (maybe it could be of some use for "preview" purposes)

Sure, a separate target makes sense. :)

@tomponline
Copy link
Member

What is causing the lxd-doc tool to be called twice now (for my understanding)?

@ru-fu
Copy link
Contributor

ru-fu commented Jul 20, 2023

What is causing the lxd-doc tool to be called twice now (for my understanding)?

It's in the Makefile as a requirement of the doc build (

lxd/Makefile

Line 129 in fc1c870

doc: lxd-doc doc-setup doc-incremental
), and in addition, the Sphinx config now contains an extension that calls it during the doc build (this PR).

@tomponline
Copy link
Member

And sphinx gets called as part of make doc?

@ru-fu
Copy link
Contributor

ru-fu commented Jul 20, 2023

And sphinx gets called as part of make doc?

Yes, it's in doc-incremental.
And actually, that's also where the generation happens - the lxd-doc target only builds the tool.

@tomponline
Copy link
Member

And sphinx gets called as part of make doc?

Yes, it's in doc-incremental. And actually, that's also where the generation happens - the lxd-doc target only builds the tool.

Ah in that case we shouldn't have a lxd-doc target, the lxd-doc tool should be build as part of the normal "make" command target.

@ru-fu
Copy link
Contributor

ru-fu commented Jul 20, 2023

Ah in that case we shouldn't have a lxd-doc target, the lxd-doc tool should be build as part of the normal "make" command target.

I think we should have a target that can be used to run the lxd-doc tool manually. In the future, we'll need this to generate the YAML file that the UI can consume.

But having the tool built as part of the main make command surely makes sense.

@tomponline
Copy link
Member

Ah in that case we shouldn't have a lxd-doc target, the lxd-doc tool should be build as part of the normal "make" command target.

I think we should have a target that can be used to run the lxd-doc tool manually. In the future, we'll need this to generate the YAML file that the UI can consume.

But having the tool built as part of the main make command surely makes sense.

Yep, happy to have a target that runs the tool, but building should take place in main target so we catch any issues as part of the main build. Ta

@gabrielmougard gabrielmougard force-pushed the feat/readthedoc branch 2 times, most recently from d56d3ef to dfa89fc Compare July 20, 2023 08:44
Makefile Outdated
@@ -120,18 +114,25 @@ endif

.PHONY: doc-setup
doc-setup:
@go version > /dev/null 2>&1 || { echo "go is not installed for lxd-doc installation."; exit 1; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think @tomponline meant to build the tool as part of the general Go build, not as part of the doc setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this here would mean that we build the tool twice when building the docs - once here in doc-setup and once during the actual doc build (conf.py).

We don't need this. But we want to see if the tool build breaks because of some code change, so it makes sense to add the tool build to the general build.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -29,7 +29,9 @@ ifeq "$(TAG_SQLITE3)" ""
@echo "Missing dqlite, run \"make deps\" to setup."
exit 1
endif

@go version > /dev/null 2>&1 || { echo "go is not installed for lxd-doc installation."; exit 1; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know enough about Go to really review this part, but the other steps for this target require Go as well. Do they already have a check whether it's installed? Or if not, should this be made more generic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, there is already an implicit check (line 10 with GOPATH ?= $(shell go env GOPATH)). I'll remove my useless check.

Makefile Outdated
@@ -30,6 +30,8 @@ ifeq "$(TAG_SQLITE3)" ""
exit 1
endif

cd lxd/config/generate && CGO_ENABLED=0 go build -o $(GOPATH)/bin/lxd-doc
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the same sort of invocation we do for the other commands, e.g.

CGO_ENABLED=0 go install -v -tags netgo ./lxd-migrate

Copy link
Contributor

Choose a reason for hiding this comment

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

@gabrielmougard Can you update this?

Makefile Outdated
@@ -30,6 +30,8 @@ ifeq "$(TAG_SQLITE3)" ""
exit 1
endif

cd lxd/config/generate && CGO_ENABLED=0 go build -o $(GOPATH)/bin/lxd-doc
@echo "LXD-DOC built successfully"
Copy link
Member

Choose a reason for hiding this comment

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

no need for this line

@tomponline
Copy link
Member

@ru-fu please let me know if/when you would like this merged. Thanks

@ru-fu
Copy link
Contributor

ru-fu commented Jul 24, 2023

@ru-fu please let me know if/when you would like this merged. Thanks

I've tested it and it seems to work, so I'm fine with merging it.
However, this PR is based on #12062, so that should probably go in first.
And there's some open comments from you on the Makefile in this PR here, which should probably be addressed.

@ru-fu ru-fu mentioned this pull request Jul 24, 2023
@tomponline
Copy link
Member

@gabrielmougard needs a rebase now.

@tomponline tomponline changed the title doc: Add a readthedoc pre-build hook to build and generate codebase doc lxddoc: Add a readthedoc pre-build hook to build and generate codebase doc Jul 24, 2023
@gabrielmougard gabrielmougard force-pushed the feat/readthedoc branch 2 times, most recently from 317691d to def8ca2 Compare July 31, 2023 09:42
Copy link
Contributor

@ru-fu ru-fu left a comment

Choose a reason for hiding this comment

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

Thanks!

@tomponline
Copy link
Member

Needs a rebase

Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
@tomponline tomponline merged commit e6c1e94 into canonical:main Aug 21, 2023
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants