digidem / mapeo-core-next

The upcoming version of Mapeo Core
MIT License
7 stars 1 forks source link

add typedoc, test doc generation #588

Closed tomasciccola closed 2 months ago

tomasciccola commented 2 months ago

This should close #586

In order for this documentation to be useful, it would be nice to know expectations for this (what things do we think are necessary to make this useful?). For now I:

EvanHahn commented 2 months ago

What if we could build these to digidem.github.io/mapeo-core-next using CI, rather than committing them to the doc/ folder?

tomasciccola commented 2 months ago

What if we could build these to digidem.github.io/mapeo-core-next using CI, rather than committing them to the doc/ folder?

Yeah, that could be an option. I really don't have a strong opinion on this. Do you see a disadvantage on committing docs to the repo? Having a dedicated page for typedoc kinda makes sense. But I also like having documentation in markdown directly on the repo. A middle ground could be:

keen on other's opinion @achou11 @gmaclennan

achou11 commented 2 months ago

I was writing a decently long response to answer the questions here but we just discussed this over a call, so will document what was agreed instead:

tomasciccola commented 2 months ago

Following andrews proposal I've basically set up documentation so that only public things gets docgenerated and commited to the repo. On the other hand I've set up a workflow so that we can publish an html version of documentation to ghpages. This is now deployed here. This is a custom domain set up for the repo. I think the idea is not to hosted there, but on the default url (so, smth like mapeo-core-next.githab.pages.io ? ). But I can't seem to find a way to ignore a custom domain for a specific page. I'm wondering if we can delete the custom domain setup for this repo (I think so since I don't think is being use for anything else in this repo) so it can be deployed to the default url. Regarding WHEN to generate the docs. For now is set up so that only updates on the main branch deploy the docs (which I think it makes sense?). After merging this PR I need to remove a protection rule so that this branch can also deploy the page. The thing that I may need some help setting up is the preview of the page. What I'm thinking is that this preview should be accessible on a PR that is going to be merged to main. For that I may need to generate a token (gonna look at this a little bit more but that seems to be the case...)

tomasciccola commented 2 months ago

Also, along side MapeoManager (which is kinda the the thing we want to generate docs for) there are some other stuff exported mostly related to fastify. We can explicitly ignore those classes (ussing a @hidden tag in the jsdoc) or just leave them there...

EvanHahn commented 2 months ago

This is looking good!

I'm wondering if we can delete the custom domain setup for this repo (I think so since I don't think is being use for anything else in this repo) so it can be deployed to the default url.

Let me know if you want me to do this.

Regarding WHEN to generate the docs. For now is set up so that only updates on the main branch deploy the docs (which I think it makes sense?). After merging this PR I need to remove a protection rule so that this branch can also deploy the page.

I think it makes sense to generate every time main changes.

After merging this PR I need to remove a protection rule so that this branch can also deploy the page.

I wonder if we can disable the branch protection only for the GitHub Actions bot. I see this in the settings:

Screenshot

The thing that I may need some help setting up is the preview of the page.

I think this can be done in a followup PR.

Also, along side MapeoManager (which is kinda the the thing we want to generate docs for) there are some other stuff exported mostly related to fastify. We can explicitly ignore those classes (ussing a @hidden tag in the jsdoc) or just leave them there...

I also think we should do this in a followup.

achou11 commented 2 months ago

not sure if disabling the custom domain for this repo will be trivial/possible based on what's described here:

https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/about-custom-domains-and-github-pages#using-a-custom-domain-across-multiple-repositories

we have the custom domain set up on our org , which means that all of the projects are subject to it. in order to override it, we need to point to a new custom domain, but I don't think we can "revert" it to the project-specific default of digidem.github.io/mapeo-core-next

achou11 commented 2 months ago

Gregor mentioned that he's set up https://core.comapeo.app/ to point to GH pages so can use that for this project

tomasciccola commented 2 months ago

Gregor mentioned that he's set up https://core.comapeo.app/ to point to GH pages so can use that for this project

I'll probably nag him later because gh complains that a subdomain need to be set up with a CNAME record, not an A record

tomasciccola commented 2 months ago

I wonder if we can disable the branch protection only for the GitHub Actions bot. I see this in the settings:

doesn't seeems like it, it won't find the Github actions bot...

tomasciccola commented 2 months ago
  1. How does docs/api/md/ get automatically updated? How do we make sure the docs stay up-to-date?

I think an interesting thing to see is the possibility of, when merging something to main or when publishing a new version, a flow is run that updates the repo markdown documentation.

2. There are a lot of links to source code. For example:
   https://github.com/digidem/mapeo-core-next/blob/518de6dcd6dbaf2011bdcd13651f82d1f74ab5cc/docs/api/md/classes/MapeoManager.md?plain=1#L69

   These links reference a Git commit ID. This means that every commit will update all these links. Maybe we could just have these update when releasing a new version of the module?

Do you think having links to the source code makes sense? Because we can also disable them...

3. Is there a way to prevent all the internal files from being included?

Currently I'm using a plugin typedoc-plugin-missing-exports that basically includes files that are referenced by a public file. This makes documentation more useful (i.e., you can see MapeoProject documentation now). The plugin doesn't have any options the allow smth like defining how deep in the dep chain it goes, so it kinda includes everything that is referenced...

4. A bunch of files seem to reference `/home/szgy/src/dd/`. When I run them on my machine, they reference _my_ working directory. Is there a way to normalize this?

Haven't found a way of fixing this yet. The files that reference an absolute path are kinda random from what I've seen

EvanHahn commented 2 months ago

I think an interesting thing to see is the possibility of, when merging something to main or when publishing a new version, a flow is run that updates the repo markdown documentation.

I think it'd be cool to do this when we publish a new version, probably as part of our existing release script (see .github/workflows/release.yml).

Do you think having links to the source code makes sense? Because we can also disable them...

I think it's probably fine to disable them for now.

Currently I'm using a plugin typedoc-plugin-missing-exports that basically includes files that are referenced by a public file. This makes documentation more useful (i.e., you can see MapeoProject documentation now). The plugin doesn't have any options the allow smth like defining how deep in the dep chain it goes, so it kinda includes everything that is referenced...

:thumbsup: Would be cool to fix this somehow in the future, not sure how.

tomasciccola commented 2 months ago

I think it'd be cool to do this when we publish a new version, probably as part of our existing release script (see .github/workflows/release.yml).

I've added a flow to release.yml to basically do this by using git and commiting the files. I've also added it to the docs.yml flow so that we can test without needing to do a release (will probably remove that step before merging though...)

Currently I'm using a plugin typedoc-plugin-missing-exports that basically includes files that are referenced by a public file. This makes documentation more useful (i.e., you can see MapeoProject documentation now). The plugin doesn't have any options the allow smth like defining how deep in the dep chain it goes, so it kinda includes everything that is referenced...

👍 Would be cool to fix this somehow in the future, not sure how.

Yeah, me neither, same with all the internal files that are named with an absolute path...

tomasciccola commented 2 months ago

Things to pay attention to:

EvanHahn commented 2 months ago

I'll plan to review tomorrow.