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

docs(typedoc): Typedoc Indexing #896

Merged
merged 2 commits into from
Dec 15, 2023
Merged

docs(typedoc): Typedoc Indexing #896

merged 2 commits into from
Dec 15, 2023

Conversation

kittybest
Copy link
Collaborator

@kittybest kittybest commented Dec 11, 2023

Description
Try the package docusaurus-plugin-typedoc at the beginning, it could automatically generate markdown files for typedocs, and put them inside doc/ folder, which is default for the Next version document in Docusaurus. Also the sidebar will also be auto-generated.
However, we will need to do something before we actually start or build the docusaurus:

  1. replace the package folder link in README.md (which should be the index page of typedoc) to github links. (currently we are doing it in the setupTypedoc.ts, by replacing the route in html file ➡️
    '<a target="_parent" href="https://github.com/privacy-scaling-explorations/maci/tree/dev/',
  2. docs/ is not the actual folder we put our documents, so will also need to move or copy the whole typedoc/ folder to versioned_docs/v1.x/.

It's hard to split the command in docusaurus-plugin-typedoc, so I instead, tried to use only typedoc-plugin-markdown. I put the scripts doing the above 2 steps in the setupTypedoc.ts file.

But there's still a problem, that the sidebar name is not setup as Typedoc. I will fix it.

Also wanna ask that the if we wanna auto-generate the index page of typedoc from the README.md? or we wanna write our own?

Last is that should we put the generated markdown files in the repo instead of ignoring them?

Copy link

netlify bot commented Dec 11, 2023

Deploy Preview for maci-typedoc ready!

Name Link
🔨 Latest commit 1f7a509
🔍 Latest deploy log https://app.netlify.com/sites/maci-typedoc/deploys/657c5becadafdc0008ef8759
😎 Deploy Preview https://deploy-preview-896--maci-typedoc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kittybest kittybest changed the base branch from dev to docs/contracts December 11, 2023 09:28
@ctrlc03
Copy link
Collaborator

ctrlc03 commented Dec 11, 2023

Description Try the package docusaurus-plugin-typedoc at the beginning, it could automatically generate markdown files for typedocs, and put them inside doc/ folder, which is default for the Next version document in Docusaurus. Also the sidebar will also be auto-generated. However, we will need to do something before we actually start or build the docusaurus:

  1. replace the package folder link in README.md (which should be the index page of typedoc) to github links. (currently we are doing it in the setupTypedoc.ts, by replacing the route in html file ➡️
    '<a target="_parent" href="https://github.com/privacy-scaling-explorations/maci/tree/dev/',
  2. docs/ is not the actual folder we put our documents, so will also need to move or copy the whole typedoc/ folder to versioned_docs/v1.x/.

It's hard to split the command in docusaurus-plugin-typedoc, so I instead, tried to use only typedoc-plugin-markdown. I put the scripts doing the above 2 steps in the setupTypedoc.ts file.

But there's still a problem, that the sidebar name is not setup as Typedoc. I will fix it.

Also wanna ask that the if we wanna auto-generate the index page of typedoc from the README.md? or we wanna write our own?

Last is that should we put the generated markdown files in the repo instead of ignoring them?

I would suggest to .gitignore them - anyways they will be generated on the gh-pages branch upon deployment

@ctrlc03 ctrlc03 requested review from ctrlc03 and removed request for ctrlc03 December 11, 2023 14:30
@ctrlc03 ctrlc03 force-pushed the docs/contracts branch 2 times, most recently from 04586fb to 5700f1f Compare December 11, 2023 15:58
@samajammin
Copy link
Member

docs/ is not the actual folder we put our documents, so will also need to move or copy the whole typedoc/ folder to versioned_docs/v1.x/.

Hmmm so is the takeaway that docusaurus-plugin-typedoc doesn't support versioned docs? That seems surprising... feels like a pretty common use of Docusarus 🤔 In any case, sounds like you found a solution to copy them over to the write location.

But there's still a problem, that the sidebar name is not setup as Typedoc. I will fix it.

What's the current name - is it the same as the directory slug? If so, I noticed the same issue in (#870 (comment))

Also wanna ask that the if we wanna auto-generate the index page of typedoc from the README.md? or we wanna write our own?

Do we need an index page? Happy to write our own if so - I can add a quick explainer. Better yet, why don't you take a quick swing at a description for it (e.g. these API docs are generated using TypeDoc for xyz packages of the repo).

Last is that should we put the generated markdown files in the repo instead of ignoring them?

I agree with @ctrlc03 I think we can gitignore these since they're autogenerated.

@ctrlc03 ctrlc03 force-pushed the docs/contracts branch 2 times, most recently from 8455b1d to 3101a60 Compare December 12, 2023 10:15
Base automatically changed from docs/contracts to dev December 12, 2023 11:55
@kittybest
Copy link
Collaborator Author

Do we need an index page? Happy to write our own if so - I can add a quick explainer. Better yet, why don't you take a quick swing at a description for it (e.g. these API docs are generated using TypeDoc for xyz packages of the repo).

Currently use the modules.md page as the index page, if anyone wants to add any description on the page, just leave a comment :) or it could be an independent issue~~

What's the current name - is it the same as the directory slug? If so, I noticed the same issue in (#870 (comment))

Yes it's actually the same question. Now it's automatically generated as just index.md (since this file is its homepage).
Since they are the same question, I think we could open an issue to deal with it, not modifying it on this branch, that would be clearer.

@samajammin samajammin added this to the MACI v1.1.1 refactor milestone Dec 12, 2023
@kittybest kittybest force-pushed the try-typedoc-md branch 2 times, most recently from d133620 to 9cf10f9 Compare December 13, 2023 16:37
@kittybest kittybest marked this pull request as ready for review December 13, 2023 16:55
@kittybest kittybest force-pushed the try-typedoc-md branch 2 times, most recently from a27964a to 633666f Compare December 14, 2023 08:24
Copy link
Collaborator

@ctrlc03 ctrlc03 left a comment

Choose a reason for hiding this comment

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

Great stuff, thanks for taking care of this. Left just a couple of minor comments

versioned_docs/version-v1.x/solidity-docs
Copy link
Collaborator

@ctrlc03 ctrlc03 Dec 14, 2023

Choose a reason for hiding this comment

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

I would also add the typedoc folder directly as someone might generate the docs but not actually run the build script inside the website folder

@@ -1,39 +1,13 @@
import fs from "fs";
import path from "path";

import { copyDirectory } from "./utils";
Copy link
Collaborator

Choose a reason for hiding this comment

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

neat

try {
const versionContent = fs.readFileSync(versionFile, "utf8");
if (versionContent) {
const versionContentJson: string[] = JSON.parse(versionContent) as string[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can remove : string[] as it's redundant (given you cast using as string[])

}
const TYPEDOC_DIR = path.resolve(__dirname, "../../typedoc");

function updateMentionFiles(dirName: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add some documentation to this function please?

@ctrlc03 ctrlc03 self-requested a review December 15, 2023 14:15
Copy link
Collaborator

@ctrlc03 ctrlc03 left a comment

Choose a reason for hiding this comment

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

Great stuff, thank you!!

@ctrlc03 ctrlc03 merged commit b64488b into dev Dec 15, 2023
12 checks passed
@ctrlc03 ctrlc03 deleted the try-typedoc-md branch December 15, 2023 14:40
@@ -6,7 +6,7 @@
"license": "MIT",
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"build": "lerna run build --ignore=website",
Copy link
Member

Choose a reason for hiding this comment

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

Why ignore website here? I suppose generally not needed when building MACI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we could only run npm run typedoc in root folder only after all the packages are built (instead of website). The npm run build command in website/ would do things to Typedocs and put them in the versioned_docs/v1.x/ folder. Which means the runnable order of the script should be

  1. build all packages
  2. build typedoc and soliditydocs
  3. build website

Of course we could ignore the setup-typedoc and setup-soliditydocs command for the first build while running lerna run build command, and build typedocs and soliditydocs, and build the website again; but I don't think we should build the website twice. That's why I ignore the website package for the first build.

@samajammin
Copy link
Member

I think we could open an issue to deal with it, not modifying it on this branch, that would be clearer.

@kittybest agreed - do you mind creating an issue to capture this?

Nice work on the PR!

@ctrlc03 ctrlc03 linked an issue Dec 15, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add TypeDoc to search
3 participants