DOCSP-4552 Add code example pasting doclet #106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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

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