Skip to content

Set up docgen for rules-unit-testing #5419

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

Merged
merged 17 commits into from
Oct 14, 2021
Merged

Set up docgen for rules-unit-testing #5419

merged 17 commits into from
Oct 14, 2021

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Aug 30, 2021

Set up api-extractor to generate reference docs for rules-unit-testing.

This runs as part of the main docgen script, in order to generate links to other packages dynamically. In order to enable being a in a separate directory, some post-processing steps are done, so this is the process:

  1. generate all docs in the repo, both JS SDK and RUT, to enable api-documenter to create links across packages.
  2. generate a set of docs from the RUT json only (only to get a separate RUT index.md) into a dedicated docs-rut folder. Any docs with links to other packages will be broken, but that is okay because
  3. move RUT docs with properly generated links from main docs folder into docs-rut folder
  4. modify paths to storage/firestore/database to point to a sibling directory

To generate docs, from the top level directory run yarn docgen:exp devsite. The resulting html docs will be in a gitignored folder, rut-docs.

Note: I decided to use the direct link to the service reference doc when talking about the instance in general, and use string literals when referring to Firestore etc. as a return type, as I guess it actually returns compat instances, where it seems wrong to imply that's what the link is going to.

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2021

⚠️ No Changeset found

Latest commit: e2bae00

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 31, 2021

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 31, 2021

Size Analysis Report

Affected Products

No changes between base commit (e456d00) and head commit (8b90630).

@google-oss-bot google-oss-bot added the doc-changes PRs that affect docs label Aug 31, 2021
Copy link
Collaborator

@markarndt markarndt left a comment

Choose a reason for hiding this comment

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

Just one docstring correction.

@hsubox76 hsubox76 changed the title WIP: Set up docgen for rules-unit-testing Set up docgen for rules-unit-testing Sep 13, 2021
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
"dtsRollup": {
"enabled": true,
Copy link
Member

Choose a reason for hiding this comment

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

Do they need dts rollup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess not, removed.

@@ -16,7 +16,8 @@
"dev": "rollup -c -w",
"test:nyc": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --config ./mocharc.node.js",
"test": "(cd functions && yarn) && firebase --project=demo-foo --debug emulators:exec 'yarn test:nyc'",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test"
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
"api-report": "api-extractor run --local --verbose"
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a command to generate docs locally, like other packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

) {
const rulesOutputFolder = `${projectRoot}/docs-rut`;

// Generate from rules-unit-testing.api.json only, to get an index.md.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this index file since it will only contain one package. The rules-unit-testing.md can be used as the entry point directly.

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 possible that the top level file needs to be named index.md for devsite, so I will check about that. If so, I can rename rules-unit-testing.md (and all links to it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it turns out the way the devsite files are structured, it also doesn't need the index.md, so just removed this.

@@ -1,6 +1,6 @@
{
"extends": "../../config/api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/dist/esm5/index.doc.d.ts",
Copy link
Member

Choose a reason for hiding this comment

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

Is it a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, must be an artifact of running global docgen and not completing the script. Removed.

@Feiyang1 Feiyang1 assigned hsubox76 and unassigned Feiyang1 Oct 4, 2021
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 5, 2021

Binary Size Report

Affected SDKs

No changes between base commit (e456d00) and head commit (8b90630).

Test Logs

@Feiyang1 Feiyang1 assigned hsubox76 and unassigned Feiyang1 Oct 14, 2021
@hsubox76 hsubox76 merged commit 5a9a144 into master Oct 14, 2021
@hsubox76 hsubox76 deleted the ch-rut-docs branch October 14, 2021 18:01
@firebase firebase locked and limited conversation to collaborators Nov 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes doc-changes PRs that affect docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants