Skip to content

Conversation

cbush
Copy link
Contributor

@cbush cbush commented Mar 1, 2019

Adds a doclet (javadoc 'plugin') that generates a manifest of which
external code examples are available for the entities.

Adds a python script using BeautifulSoup to edit the resulting HTML
output of javadoc to inject the code examples.

Adds a couple code examples for starters (borrowed from the main docs
site). To come: testing code examples and just more code examples,
plus styling of the overall javadoc output.

Finally, it adds a generate_docs.sh script, similar to JS SDK.

A note on this approach:

From what I can tell, it is not possible to leverage the existing
javadoc HTML doclet implementation while modifying it as HtmlDoclet
is private to the JDK.

It's also not possible to modify the entities passed to my doclet,
e.g. to inject new code example tags. The entities are completely
immutable when passed to my doclet.

Failing all that, I thought maybe I could override the overall
DocletEnvironment context to return my own brand new tree of entities
with tags injected -- i.e. use the decorator pattern to pass a custom
DocletEnvironment implementation that wraps their implementation
to the StandardDoclet. Unfortunately, the JDK downcasts to their
concrete DocEnvImpl type somewhere deep in the code, which makes
that approach also impossible.

So, here we are at programmatically editing the HTML after the javadoc
step has completed.

Staged

https://docs-mongodbcom-staging.corp.mongodb.com/stitch/bush/docs-examples/sdk/android/

Pages with injected examples (more styling to come):

https://docs-mongodbcom-staging.corp.mongodb.com/stitch/bush/docs-examples/sdk/android/com/mongodb/stitch/core/services/mongodb/remote/RemoteUpdateResult.html

https://docs-mongodbcom-staging.corp.mongodb.com/stitch/bush/docs-examples/sdk/android/com/mongodb/stitch/android/services/mongodb/remote/RemoteMongoCollection.html (scroll down to updateOne​(Bson filter, Bson update, RemoteUpdateOptions updateOptions) details)

Screenshots

Class example
image

Note the "example" block matches the other section blocks below (constructor summary, methods, etc.)

image

Method example
image

@cbush cbush requested review from adamchel and dkaminsky March 1, 2019 21:02
Adds a doclet (javadoc 'plugin') that generates a manifest of which
external code examples are available for the entities.

Adds a python script using BeautifulSoup to edit the resulting HTML
output of javadoc to inject the code examples.

Adds a couple code examples for starters (borrowed from the main docs
site). To come: testing code examples and just more code examples,
plus styling of the overall javadoc output.

Finally, it adds a generate_docs.sh script, similar to JS SDK.

A note on this approach:

From what I can tell, it is not possible to leverage the existing
javadoc HTML doclet implementation while modifying it as HtmlDoclet
is private to the JDK.

It's also not possible to modify the entities passed to my doclet,
e.g. to inject new code example tags. The entities are completely
immutable when passed to my doclet.

Failing all that, I thought maybe I could override the overall
DocletEnvironment context to return my own brand new tree of entities
with tags injected -- i.e. use the decorator pattern to pass a custom
DocletEnvironment implementation that wraps their implementation
to the StandardDoclet. Unfortunately, the JDK downcasts to their
concrete DocEnvImpl type somewhere deep in the code, which makes
that approach also impossible.

So, here we are at programmatically editing the HTML after the javadoc
step has completed.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 66.146% when pulling 3e9a777 on cbush:docs-examples into a1eeaa3 on mongodb:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 66.146% when pulling 3e9a777 on cbush:docs-examples into a1eeaa3 on mongodb:master.

@adamchel adamchel removed their request for review March 4, 2019 21:19
Copy link
Contributor

@dkaminsky dkaminsky left a comment

Choose a reason for hiding this comment

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

lgtm as a first stab

@cbush cbush merged commit 2e7fa83 into mongodb:master Mar 5, 2019
@cbush cbush deleted the docs-examples branch March 5, 2019 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants