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

[OIL] Split the API reference markdown into smaller files and use templates to generate it. #5338

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

kc284
Copy link
Contributor

@kc284 kc284 commented Jan 8, 2024

The API reference file has become too big (~1.5MB) and keeps increasing. The result is that the corresponding webpage takes several seconds to download, so we decided to split it to smaller bits and have a file per class.

@@ -1,3 +1,7 @@
---
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These headers are a particularity of XS docs. If there is an issue with having them here, I can remove them and have the pipeline insert them later (since it will have to replace the @root@ placeholders in some files anyway).


# API Reference

Version **@xapi-version@**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there an easy way to have this replaced during build time? If not, I can have the pipeline replace it later).

Copy link
Member

@psafont psafont Jan 9, 2024

Choose a reason for hiding this comment

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

Currently, the version is embedded into binaries using the Xapi_version module and using the dune-build-info library. One way to do it would be to it would be to create an ocaml binary that processes this file.

One way you can try is to use dune subst, and use %%VERSION%%. I believe it's intended to be used project-wide, but you're welcome to try

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip; I won't consider this as a blocker for this PR though (it's probably not a big change, but I only have time to work on this on and off, so I'd rather get the PR in the soonest possible and improve the versioning later).

Copy link
Member

@psafont psafont Jan 12, 2024

Choose a reason for hiding this comment

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

Had a look, and the binary that generates the files already has access to this library, So it can already use mustache templates to generate it.

The only complication is that the binary needs to be "installed" before it generated the files so it can pick up the version, because of how dune injects the version, I've done this in psafont@13da274

But it needs testing to ensure that the version injected in the CI is simply the tag, and not either of these types:

# API Reference

Version 23.32.0-52-g13da274
# API Reference

Version 24.999.999-dirty

(this happens when the commit is untagged, and when make is run before make doc, respectively)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, building in the CI yields 0.0.dev. In the interest of avoiding taking up too much of people's time, I can always leave it as is and replace it later in the pipeline alongside @root@.

@kc284 kc284 self-assigned this Jan 8, 2024
@kc284 kc284 force-pushed the api-ref branch 2 times, most recently from d107868 to 8db76b3 Compare January 8, 2024 14:01
@kc284
Copy link
Contributor Author

kc284 commented Jan 9, 2024

Note that this PR does not necessarily need Interfaces reviewers.

@@ -0,0 +1,6 @@
(alias
Copy link
Contributor

Choose a reason for hiding this comment

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

this is an alias with a name and dependency, but where is the action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No action, just using source_tree to include all the files that will be generated in here. We have a few more dune files with rules like this.

dune exec --profile=$(PROFILE) -- ocaml/idl/datamodel_main.exe -closed -markdown $(XAPIDOC)/markdown
cp ocaml/doc/*.dot ocaml/doc/doc-convert.sh $(XAPIDOC)
#markdown
dune build --profile=$(PROFILE) -f @ocaml/idl/markdowngen
Copy link
Contributor

Choose a reason for hiding this comment

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

we could define some install sections in dune and let dune install things into the right places. The method of installing files in the Makefile was from the time when we didn't have dune.
Then also the version substitutions inside the markdown files might work

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I'm missing something, it doesn't seem to me that I can do this efficiently with the version of dune we're currently using. All the useful stanzas (source_trees, glob_files, include) have been added in various 3.x versions.The install sections I see in other dune files in the repo handle single files, but here there is a good number of autogenerated files that have to be installed.

@psafont
Copy link
Member

psafont commented Mar 4, 2024

Is there a way to check the output of this PR?

For now I can see that classes.png is not being generated from classes.dot (this is generated by running doc-convert.sh)

@psafont
Copy link
Member

psafont commented Mar 4, 2024

How nice, that hasn't happened since before the introduction of GPU datatypes :(

Makefile Show resolved Hide resolved
@kc284 kc284 force-pushed the api-ref branch 2 times, most recently from 36219ef to 14999d9 Compare March 4, 2024 17:19
Copy link
Member

@danilo-delbusso danilo-delbusso left a comment

Choose a reason for hiding this comment

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

One last comment. This may need input from other xapi devs:

Certificate's description is just the word "Description" and Bond doesn't even have one.

We could add them in this PR, maybe?

I was thinking @psafont or @edwintorok could weigh in on a proper description

ocaml/idl/templates/api_errors.mustache Outdated Show resolved Hide resolved
ocaml/idl/templates/api_errors.mustache Outdated Show resolved Hide resolved
ocaml/idl/markdown_backend.ml Show resolved Hide resolved
ocaml/idl/templates/class.mustache Show resolved Hide resolved
ocaml/idl/templates/class.mustache Outdated Show resolved Hide resolved
ocaml/idl/templates/relationships.mustache Outdated Show resolved Hide resolved
ocaml/idl/templates/types.mustache Outdated Show resolved Hide resolved
ocaml/idl/templates/types.mustache Outdated Show resolved Hide resolved
ocaml/idl/templates/types.mustache Show resolved Hide resolved
ocaml/doc/basics.md Show resolved Hide resolved
diagramatically, using crow's foot notation to specify one-to-one,
one-to-many, or many-to-many relationships:

![Class relationships](classes.png 'Class relationships')
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused, where is this image in the source? I can see it on https://xapi-project.github.io/xen-api/ but not here. :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's autogenerated from the .dot file. The internal pipeline does it, I haven't looked into github actions because that was done a long time ago (and I'll consider it out of scope for this PR).

@psafont
Copy link
Member

psafont commented Mar 8, 2024

One last comment. This may need input from other xapi devs:

Certificate's description is just the word "Description" and Bond doesn't even have one.

We could add them in this PR, maybe?

For Certificate, the description can be "An X509 certificate used for TLS connections". For Bond, maybe "A Network bond that combines physical network interfaces, also known as link aggregation"?

@kc284
Copy link
Contributor Author

kc284 commented Mar 8, 2024

Thanks @psafont, I'll add these. Note that there are several more missing or suboptimal descirptions in xapi (secret is a notorious one), I think we need a separate PR to fix all those.

kc284 added 2 commits March 8, 2024 16:35
Signed-off-by: Konstantina Chremmou <[email protected]>
@kc284
Copy link
Contributor Author

kc284 commented Mar 8, 2024

I also rebased on master. The changes requested are in a separate commit, see here 37821d8

@psafont psafont merged commit b95a075 into xapi-project:master Mar 11, 2024
28 checks passed
@kc284 kc284 deleted the api-ref branch March 11, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants