Skip to content

docs: compile the code samples and publish the API reference - #2521

Open
mykola-mokhnach wants to merge 2 commits into
masterfrom
docs/snippets-and-api
Open

mykola-mokhnach wants to merge 2 commits into
masterfrom
docs/snippets-and-api

Conversation

@mykola-mokhnach

Copy link
Copy Markdown
Contributor

Phase 2 of the documentation plan: code samples that are compiled, and an API reference published with every docs version.

Compiled code samples

  • New docs-snippets Gradle subproject with compile-only samples (depends on core, selenium-bridge and selenium-support). Pages include them with --8<-- "File.java:section" (pymdownx.snippets; markers and indentation are stripped). A missing section fails the site build, and the main ./gradlew build compiles the samples, so an API change that breaks an example fails the PR that made it.
  • selenium-bridge.md (3 blocks) and The-event_firing.md (4 blocks) are converted. The other pages still have inline blocks that are mostly stale (see the inventory); they are converted when they are rewritten.
  • Compiling the event listener samples and checking the page against the source found things that were wrong:
    • IOSDriver<?> (the class is no longer generic) and element::click; (not valid Java);
    • the "does not work" decorator example does not throw the documented ClassCastException: with IOSDriver.class passed it fails with AssertionError: Unable to create new proxy; the cast failure is what happens without the class argument, so the sample and the explanation are fixed accordingly;
    • ElementAwareWebDriverListener wraps AppiumWebElement, not RemoteWebElement;
    • the page never said that EventFiringDecorator needs selenium-support.

API reference

  • docsApi generates one merged Javadoc (core + selenium-bridge; list in apiModules) into the git-ignored docs/api, and the nav links to it. It runs before the site build and docsDeploy, so each docs version carries the Javadoc of its own code. -notimestamp keeps the docs-site history small.
  • The site generator only validates links to pages, so docsCheckApiLinks checks the api/... links in the pages itself.

Guard

  • docsCheckInlineCode fails if a page outside gradle/docs-legacy-inline-code.txt has a new multi-line java block that is not an include. The four pages that still have inline Java are on the list and leave it when they are rewritten.
  • Authoring rules are documented in docs/Note-for-developers.md; the Docs workflow also runs on docs-snippets/**.

Notes

  • The Selenium snapshot CI jobs now also compile the samples, so a breaking Selenium API change shows up there.
  • The dev docs are published when docs files change, not on every src/main change, so the dev API reference can lag behind master until the next docs change or release.

Testing

  • ./gradlew docsCheck from a clean state (no docs/api, no build/docs-site): green in about 6 seconds.
  • Negative checks: a missing snippet section, a link to a missing Javadoc page and a new multi-line inline Java block each fail the build.
  • Verified the documented ClassCastException behavior by running the sample against the current Selenium.

- docs-snippets subproject with compile-only samples, included into the pages
  with pymdownx.snippets; selenium-bridge.md and The-event_firing.md converted
- fix the event firing page where it differed from the code (stale examples,
  decorator failure mode, AppiumWebElement, selenium-support requirement)
- docsApi: merged Javadoc of core and selenium-bridge generated into docs/api
  and linked from the nav, so every docs version has its own API reference
- docsCheckApiLinks and docsCheckInlineCode checks; legacy pages with inline
  Java are allow-listed until they are rewritten
- docs workflow also runs on docs-snippets changes
Comment thread mkdocs.yml Resolved

`./gradlew docsApi` generates the merged Javadoc of the published modules into `docs/api` (not committed); the site
build and `docsServe` run it first, so every docs version contains the Javadoc of its own code. Link to it with a
relative URL, for example ``[`AppiumDriver`](api/io/appium/java_client/AppiumDriver.html)``. `docsCheck` fails if

@eglitise eglitise Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if these links should lead to HTML. Zensical recommends linking to the Markdown file (https://zensical.org/docs/authoring/markdown/#linking-between-pages) though I'm not sure such files would exist for the API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Javadoc is generated HTML (docs/api is built by docsApi and git-ignored), so there are no Markdown sources to link to. The Markdown-link recommendation only applies between Markdown pages, and strict mode would not resolve .md targets for the API. That is why docsCheckApiLinks validates these .html links against the generated tree instead. Keeping them as relative .html links.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants