Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Generate MD docs for all packages #2033

Merged
merged 38 commits into from
Aug 26, 2019
Merged

Generate MD docs for all packages #2033

merged 38 commits into from
Aug 26, 2019

Conversation

fabioberger
Copy link
Contributor

@fabioberger fabioberger commented Aug 3, 2019

Description

This PR:

  • Adds the ability to generate markdown doc pages for our packages.
  • It generates the reference.md for the current version of each package that currently has a doc page.
  • It adds MD doc generation and S3 uploading to the publish flow.

The Docs 2.0 site will then involve pulling down the latest versions from S3, indexing the MD files on Algolia and bundling them into the site for faster loading times.

What is cool about this approach is that even packages that live outside the monorepo can be searchable/renderable on the Docs 2.0 site (e.g., the TS client for Mesh 0xProject/0x-mesh#334).

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@buildsize
Copy link

buildsize bot commented Aug 3, 2019

File name Previous Size New Size Change
init.py 7.04 KB [deleted]
abi_gen_dummy.ts 145.2 KB [deleted]
lib_dummy.ts 4.82 KB [deleted]
test_lib_dummy.ts 12.7 KB [deleted]
environment.pickle 1.56 MB 1.56 MB 0 bytes (0%)
index.doctree 190.99 KB 190.99 KB 0 bytes (0%)
.buildinfo 230 bytes 230 bytes 0 bytes (0%)
genindex.html 5.6 KB 5.6 KB 0 bytes (0%)
index.html 2.52 KB 2.52 KB 0 bytes (0%)
objects.inv 375 bytes 375 bytes 0 bytes (0%)
py-modindex.html 3.07 KB 3.07 KB 0 bytes (0%)
search.html 2.84 KB 2.84 KB 0 bytes (0%)
searchindex.js 5.82 KB 5.82 KB 0 bytes (0%)
index.rst.txt 415 bytes 415 bytes 0 bytes (0%)
alabaster.css 10.92 KB 10.92 KB 0 bytes (0%)
basic.css 11.89 KB 11.89 KB 0 bytes (0%)
custom.css 42 bytes 42 bytes 0 bytes (0%)
doctools.js 9.05 KB 9.05 KB 0 bytes (0%)
documentation_options.js 303 bytes 303 bytes 0 bytes (0%)
file.png 286 bytes 286 bytes 0 bytes (0%)
jquery-[version].js 273.79 KB 273.79 KB 0 bytes (0%)
jquery.js 86.08 KB 86.08 KB 0 bytes (0%)
language_data.js 10.59 KB 10.59 KB 0 bytes (0%)
minus.png 90 bytes 90 bytes 0 bytes (0%)
plus.png 90 bytes 90 bytes 0 bytes (0%)
pygments.css 4.69 KB 4.69 KB 0 bytes (0%)
searchtools.js 15.61 KB 15.61 KB 0 bytes (0%)
underscore-[version].js 34.34 KB 34.34 KB 0 bytes (0%)
underscore.js 11.86 KB 11.86 KB 0 bytes (0%)
contract_addresses.html 17.89 KB 17.89 KB 0 bytes (0%)
contract_artifacts.html 8.24 KB 8.24 KB 0 bytes (0%)
_bootstrap.html 142.73 KB 142.73 KB 0 bytes (0%)
json_schemas.html 12.43 KB 12.43 KB 0 bytes (0%)
order_utils.html 44.83 KB 44.83 KB 0 bytes (0%)
erc20_token.html 88.14 KB 88.14 KB 0 bytes (0%)
exchange.html 506.16 KB 506.16 KB 0 bytes (0%)
tx_params.html 8.83 KB 8.83 KB 0 bytes (0%)
local_message_signer.html 15.07 KB 15.07 KB 0 bytes (0%)
asset_data_utils.html 22.65 KB 22.65 KB 0 bytes (0%)
default_api.html 118.49 KB 118.49 KB 0 bytes (0%)
globals.html 13.39 KB [deleted]
asset_proxy_owner.assetproxyownercontract.html 446.56 KB [deleted]
coordinator.coordinatorcontract.html 157.58 KB [deleted]
coordinator_registry.coordinatorregistrycontract.html 97.7 KB [deleted]
dummy_erc20_token.dummyerc20tokencontract.html 265.44 KB [deleted]
dummy_erc721_token.dummyerc721tokencontract.html 312.47 KB [deleted]
dutch_auction.dutchauctioncontract.html 150.53 KB [deleted]
erc20_proxy.erc20proxycontract.html 190.21 KB [deleted]
erc20_token.erc20tokencontract.html 160.91 KB [deleted]
erc721_proxy.erc721proxycontract.html 190.53 KB [deleted]
erc721_token.erc721tokencontract.html 221.79 KB [deleted]
eth_balance_checker.ethbalancecheckercontract.html 63.84 KB [deleted]
exchange.exchangecontract.html 773.67 KB [deleted]
forwarder.forwardercontract.html 180.32 KB [deleted]
i_asset_proxy.iassetproxycontract.html 179.55 KB [deleted]
i_validator.ivalidatorcontract.html 63.85 KB [deleted]
i_wallet.iwalletcontract.html 62.77 KB [deleted]
multi_asset_proxy.multiassetproxycontract.html 230.27 KB [deleted]
order_validator.ordervalidatorcontract.html 137.33 KB [deleted]
weth9.weth9contract.html 213.72 KB [deleted]
zrx_token.zrxtokencontract.html 178.78 KB [deleted]
asset_proxy_owner.assetproxyownerevents.html 26.64 KB [deleted]
coordinator_registry.coordinatorregistryevents.html 12.94 KB [deleted]
dummy_erc20_token.dummyerc20tokenevents.html 13.85 KB [deleted]
dummy_erc721_token.dummyerc721tokenevents.html 15.18 KB [deleted]
erc20_proxy.erc20proxyevents.html 14.06 KB [deleted]
erc20_token.erc20tokenevents.html 13.67 KB [deleted]
erc721_proxy.erc721proxyevents.html 14.09 KB [deleted]
erc721_token.erc721tokenevents.html 14.95 KB [deleted]
exchange.exchangeevents.html 17.26 KB [deleted]
multi_asset_proxy.multiassetproxyevents.html 15.62 KB [deleted]
weth9.weth9events.html 15.63 KB [deleted]
zrx_token.zrxtokenevents.html 13.58 KB [deleted]
asset_proxy_owner.assetproxyownerassetproxyregistrationeventargs.html 17.4 KB [deleted]
asset_proxy_owner.assetproxyownerconfirmationeventargs.html 17.2 KB [deleted]
asset_proxy_owner.assetproxyownerconfirmationtimeseteventargs.html 17.35 KB [deleted]
asset_proxy_owner.assetproxyownerdepositeventargs.html 17.08 KB [deleted]
asset_proxy_owner.assetproxyownerexecutioneventargs.html 16.24 KB [deleted]
asset_proxy_owner.assetproxyownerexecutionfailureeventargs.html 16.29 KB [deleted]
asset_proxy_owner.assetproxyownerowneradditioneventargs.html 16.19 KB [deleted]
asset_proxy_owner.assetproxyownerownerremovaleventargs.html 16.18 KB [deleted]
asset_proxy_owner.assetproxyownerrequirementchangeeventargs.html 16.24 KB [deleted]
asset_proxy_owner.assetproxyownerrevocationeventargs.html 17.18 KB [deleted]
asset_proxy_owner.assetproxyownersubmissioneventargs.html 16.25 KB [deleted]
asset_proxy_owner.assetproxyownertimelockchangeeventargs.html 16.32 KB [deleted]
coordinator_registry.coordinatorregistrycoordinatorendpointseteventargs.html 14.82 KB [deleted]
dummy_erc20_token.dummyerc20tokenapprovaleventargs.html 15.51 KB [deleted]
dummy_erc20_token.dummyerc20tokentransfereventargs.html 15.47 KB [deleted]
dummy_erc721_token.dummyerc721tokenapprovaleventargs.html 15.84 KB [deleted]
dummy_erc721_token.dummyerc721tokenapprovalforalleventargs.html 15.89 KB [deleted]
dummy_erc721_token.dummyerc721tokentransfereventargs.html 15.79 KB [deleted]
erc20_proxy.erc20proxyauthorizedaddressaddedeventargs.html 14.57 KB [deleted]
erc20_proxy.erc20proxyauthorizedaddressremovedeventargs.html 14.59 KB [deleted]
erc20_token.erc20tokenapprovaleventargs.html 15.29 KB [deleted]
erc20_token.erc20tokentransfereventargs.html 15.25 KB [deleted]
erc721_proxy.erc721proxyauthorizedaddressaddedeventargs.html 14.61 KB [deleted]
erc721_proxy.erc721proxyauthorizedaddressremovedeventargs.html 14.63 KB [deleted]
erc721_token.erc721tokenapprovaleventargs.html 15.61 KB [deleted]
erc721_token.erc721tokenapprovalforalleventargs.html 15.66 KB [deleted]
erc721_token.erc721tokentransfereventargs.html 15.56 KB [deleted]
exchange.exchangeassetproxyregisteredeventargs.html 15.07 KB [deleted]
exchange.exchangecanceleventargs.html 18.92 KB [deleted]
exchange.exchangecanceluptoeventargs.html 16.03 KB [deleted]
exchange.exchangefilleventargs.html 23.83 KB [deleted]
exchange.exchangesignaturevalidatorapprovaleventargs.html 16.19 KB [deleted]
multi_asset_proxy.multiassetproxyassetproxyregisteredeventargs.html 15.05 KB [deleted]
multi_asset_proxy.multiassetproxyauthorizedaddressaddedeventargs.html 15.05 KB [deleted]
multi_asset_proxy.multiassetproxyauthorizedaddressremovedeventargs.html 15.07 KB [deleted]
weth9.weth9approvaleventargs.html 15.43 KB [deleted]
weth9.weth9depositeventargs.html 14.54 KB [deleted]
weth9.weth9transfereventargs.html 15.39 KB [deleted]
weth9.weth9withdrawaleventargs.html 14.57 KB [deleted]
zrx_token.zrxtokenapprovaleventargs.html 15.18 KB [deleted]
zrx_token.zrxtokentransfereventargs.html 15.14 KB [deleted]
asset_proxy_owner.html 21.12 KB [deleted]
coordinator.html 10.65 KB [deleted]
coordinator_registry.html 13.46 KB [deleted]
dummy_erc20_token.html 13.89 KB [deleted]
dummy_erc721_token.html 14.66 KB [deleted]
dutch_auction.html 10.67 KB [deleted]
erc20_proxy.html 13.87 KB [deleted]
erc20_token.html 13.65 KB [deleted]
erc721_proxy.html 13.91 KB [deleted]
erc721_token.html 14.37 KB [deleted]
eth_balance_checker.html 10.74 KB [deleted]
exchange.html 15.43 KB [deleted]
forwarder.html 10.63 KB [deleted]
i_asset_proxy.html 10.67 KB [deleted]
i_validator.html 10.64 KB [deleted]
i_wallet.html 10.62 KB [deleted]
multi_asset_proxy.html 14.92 KB [deleted]
order_validator.html 10.69 KB [deleted]
weth9.html 14.47 KB [deleted]
zrx_token.html 13.5 KB [deleted]
main.css 69.04 KB [deleted]
main.css.map 30.1 KB [deleted]
icons.png 9.26 KB [deleted]
[email protected] 27.09 KB [deleted]
widgets.png 480 bytes [deleted]
[email protected] 855 bytes [deleted]
main.js 148.53 KB [deleted]
search.js 581.48 KB [deleted]
erc1155_proxy.erc1155proxycontract.html 217.55 KB [deleted]
static_call_proxy.staticcallproxycontract.html 73.06 KB [deleted]
erc1155_proxy.erc1155proxyevents.html 14.12 KB [deleted]
erc1155_proxy.erc1155proxyauthorizedaddressaddedeventargs.html 14.64 KB [deleted]
erc1155_proxy.erc1155proxyauthorizedaddressremovedeventargs.html 14.66 KB [deleted]
erc1155_proxy.html 13.95 KB [deleted]
static_call_proxy.html 10.72 KB [deleted]
asset_proxy_owner.html 341.77 KB 341.77 KB 0 bytes (0%)
coordinator.html 127.47 KB 127.47 KB 0 bytes (0%)
coordinator_registry.html 36.15 KB 36.15 KB 0 bytes (0%)
dutch_auction.html 54.84 KB 54.84 KB 0 bytes (0%)
erc20_proxy.html 105.63 KB 105.63 KB 0 bytes (0%)
erc721_proxy.html 105.72 KB 105.72 KB 0 bytes (0%)
erc721_token.html 141.96 KB 141.96 KB 0 bytes (0%)
eth_balance_checker.html 21.03 KB 21.03 KB 0 bytes (0%)
forwarder.html 107.42 KB 107.42 KB 0 bytes (0%)
i_asset_proxy.html 89.89 KB 89.89 KB 0 bytes (0%)
i_validator.html 26.24 KB 26.24 KB 0 bytes (0%)
i_wallet.html 23.61 KB 23.61 KB 0 bytes (0%)
multi_asset_proxy.html 141.39 KB 141.39 KB 0 bytes (0%)
order_validator.html 115.34 KB 115.34 KB 0 bytes (0%)
weth9.html 129.04 KB 129.04 KB 0 bytes (0%)
zrx_token.html 107.34 KB 107.34 KB 0 bytes (0%)
dev_utils.devutilscontract.html 310.7 KB [deleted]
dev_utils.html 10.63 KB [deleted]
dev_utils.html 339.53 KB 339.53 KB 0 bytes (0%)

@coveralls
Copy link

coveralls commented Aug 3, 2019

Coverage Status

Coverage remained the same at 80.256% when pulling e452cfc on feature/genMDDocs into cbb40c1 on development.

@feuGeneA
Copy link
Contributor

feuGeneA commented Aug 9, 2019

I haven't reviewed all of this, but I wanted to discourage you from checking in generated code. (Deja vu? :P)

If I understand correctly, the workflow is set up such that someone could make changes to some TypeScript and forget to also check in changes to the generated markdown. This sounds like a recipe for confusion and headache. The next person who DOES try to update the markdown will have to sift through a bunch of changes that are reflective of prior work, and any reviewer would have to go digging through commit histories in order to make sense of it all.

To me the best thing to do would be to not check these in at all, and to persist them as CircleCI Build Artifacts. (See usage of store_artifacts in .circleci/config.yml.) These generated markdown files are build artifacts, and are not hand-written, maintained code, so I think this is the right approach for them.

However, I realize there's an argument to be made that persisting as Build Artifacts rather than checked-in code does make it difficult to review changes to the generated markdown. But I would counter that argument by saying that it's always difficult to review a change in rendering (I've always wondered how a web developer reviews changes to the rendering of HTML/JS code in a PR...) and that as a user of a renderer we should just trust that the renderer is tested properly and not doing anything stupid on our behalf.

If you must insist that we keep checking in these markdown files, I suggest adding a test that will fail if someone changes the TypeScript source without also updating the generated markdown. This is the approach we plan to take for the abi-gen/test-cli output, which is described in #2012 .

@fabioberger
Copy link
Contributor Author

@feuGeneA actually the MD docs will only be generated during the publishing flow and auto-commited to Github along with the updated CHANGELOGS. No one will ever need to review them. We only guarantee that the docs at the publish commit are reflective of the packages at that version, not every intermediate state after each PR.

Do you now agree with the decision to commit them? It's nice to have the docs in the commit history for every version through time.

@feuGeneA
Copy link
Contributor

feuGeneA commented Aug 9, 2019

I'm sorry to be a stickler, but I still disagree that they should be checked in. I love the idea of having a canonical/authoritative place for generated docs, and of having a versioning system that explicitly associates them with particular releases, but I don't think the source tree is the right place for that. These are artifacts, not code.

It sounds these markdown files are beyond just "build artifacts", and could accurately be described as "release artifacts." Could we leverage the GitHub Releases .zip files as the authoritative place to find the generated docs associated with a particular version?

To be clear, I'm not trying to be a purist, and I want to advocate pragmatism. If what you've got here is the most practical solution, then don't let me be a blocker. (I for one wouldn't know where to start with GitHub Releases and could see myself taking the tech-debt-incurring shortcut of just checking these in.) But I do feel pretty strongly that a repo is for source code, not artifacts (whether build, release, or otherwise), and that if we have a good-enough and not-too-onerous mechanism for a particular type of artifact then we should utilize it, and since we do have a mechanism at our disposal for "release artifacts" then we should at least consider using it.

@feuGeneA
Copy link
Contributor

feuGeneA commented Aug 9, 2019

One other thought: If you took the GitHub Releases .zip file approach, maybe then you could skip the S3 step and have the Docs 2.0 site pull the markdown straight from GitHub? I dunno if that makes sense or not, but I wanted to throw it out there for consideration.

@dekz
Copy link
Member

dekz commented Aug 10, 2019

What is the benefit of having the mdx files checked into the source code? Is it a requirement for something else or just a nice to have?

They're generated on publish. Then versioned and uploaded to s3. They likely also exist in the published npm module.

I agree with Gene that we shouldn't have artifacts in the repository which aren't necessary for a usable module, e.g #2044, generated wrappers.

If they're used for some other piece of functionality, could they be retrieved via the npm package which would contain these files?

packages/asset-buyer/docs/reference.mdx Outdated Show resolved Hide resolved
packages/asset-buyer/docs/reference.mdx Outdated Show resolved Hide resolved
packages/asset-buyer/docs/reference.mdx Show resolved Hide resolved
@fabioberger
Copy link
Contributor Author

@feuGeneA @dekz S3 will hold MD docs for all 0x packages, across multiple repos, and not only for monorepo packages. This makes it a more sensible place then the release zip. Secondly, the release zip is a very user-unfriendly way of browsing the docs for a package, it is hard to find, requires a download and unzip to read.

The MD doc files within the monorepo is a nice-to-have. It's not used by anything but is more for someone preferring to use Github to explore our packages instead of our website. It's also about keeping the docs for posterity's sake, our site will only show the docs for the last 10 versions of a package. If you want the docs for an older package, you have to browse for it on Github.

Packaging the docs into the NPM published code is an alternative approach we could consider but it'll increase the bundle size which is not desirable. We could have people browse our S3 bucket but that won't render the markdown nicely. Although I agree with the premise of the argument, I don't think these should cause anyone any grief given that they are only updated during the publish flow, will never be reviewed by a human and won't cause any merge conflicts.

@dekz
Copy link
Member

dekz commented Aug 11, 2019

Packaging the docs into the NPM also makes it available offline where the other options require an internet connection to read the docs.

I don't think the size increase is going to be large in an node module, since the docs can be compressed well as it is non binary data. Does the same practice hold for other ecosystems though? I.e in go/python deps?

I agree that a .zip file is not a great user experience in getting to the docs.


• **exchangeAddress**: *string*

*Inherited from void*
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm do we need these Inherited from void lines? They are everywhere, any way to get rid of them?

Copy link
Contributor

@xianny xianny left a comment

Choose a reason for hiding this comment

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

If I understand correctly, sounds like docs in GH are guaranteed to be consistent with code at publish commits, but not otherwise? I think this is OK, just want to make sure I haven't made a wrong assumption.

I'm generally in favour of having docs in Github:

  • preserve old versions
  • minimise additional knowledge and steps needed to get to docs from code, since it's in the same location
  • all our docs are text-based, so we can see line-by-line diffs of docs between releases. useful for going back and understanding changes

I think the main argument against putting docs in the same place as source code is that it makes sharing difficult if you have access control on the source code - but we don't. 🤷‍♂

To me the question is more one of - do we need to commit generated code? And if no, what if we just put a note in the README that says something like "To view documentation locally, run yarn docs:md"? That would be so much simpler to maintain AND access than to store it in yet another location. If you've got the code, you've got the docs.

To be clear, we would still maintain docs for recent versions on our website via the publish workflow. Adding a note like that would just enable people to see old versions and access locally.

@fabioberger
Copy link
Contributor Author

Thanks Xianny. Yes, your understand is correct. There is one issue with your proposal, and that is that it would require a user wanting to read the docs to clone our repo, run yarn install and then yarn generate_md_docs, which isn't as easy as browsing files on Github.

I really appreciate everyone's commitment to avoiding adding generated artifacts to the repo but in this case, there isn't really a way to get an easy end-developer experience otherwise (minus @dekz's approach of bundling them into NPM packages which comes at the cost of increased bundle sizes).

@feuGeneA
Copy link
Contributor

Is increased bundle sizes really an issue? We're talking human-readable text, which gets compressed typically 10:1 or better. (Not saying it's not an issue, just saying, perhaps do a quick measure before deciding it is.)

@feuGeneA
Copy link
Contributor

they are only updated during the publish flow, will never be reviewed by a human and won't cause any merge conflicts.

How can you be so sure? Would you be up for a simple test to enforce it? Like #2012 .

If really never to be reviewed by a human, please tag them as generated in .gitattributes?

@feuGeneA
Copy link
Contributor

Would you be up for a simple test to enforce it? Like #2012 .

quick tldr: during CI runs do a git diff folder-holding-generated-markdown. if return code is non-zero, the markdown generation process produced changes that were not checked in, so the build should fail.

@xianny
Copy link
Contributor

xianny commented Aug 12, 2019

There is one issue with your proposal, and that is that it would require a user wanting to read the docs to clone our repo, run yarn install and then yarn generate_md_docs, which isn't as easy as browsing files on Github.

Yeah, that's correct. I feel pretty neutral about having generated docs on GH. My suggestion was if we decide not to commit the generated docs, I think it would be easier to prompt users to generate locally from the code they are already looking at, than to have them search for our S3, git release files, etc. I think bundling with npm is the most user-friendly solution but self-generating is easy if we are really really opposed to that.

I think adding docs to GH does add some overhead, but I also think being able to see diffs between docs could be useful.

@fabioberger
Copy link
Contributor Author

Thanks for all the ideas and discussions. Turns out the MD files can get quite large (1MB uncompressed for @0x/contract-wrappers for instance). I've therefore decided to keep the MD files in Github, but to add a CI test to make sure they are never modified in a regular PR. This will avoid all merge-conflicts.

Copy link
Member

@dekz dekz left a comment

Choose a reason for hiding this comment

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

One strange type reference which could across multiple reference.mdx files but once that is fixed should be good to go.

packages/asset-swapper/docs/reference.mdx Outdated Show resolved Hide resolved
@fabioberger fabioberger merged commit ad83b17 into development Aug 26, 2019
@fabioberger fabioberger deleted the feature/genMDDocs branch August 26, 2019 06:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants