Skip to content
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

4.x - Externalize and compile documentation java snippets #8294

Merged

Conversation

romain-grecourt
Copy link
Contributor

@romain-grecourt romain-grecourt commented Jan 25, 2024

Description

Fixes #8293
Fixes #8313

Externalize and compile docs java snippets.
Introduce conventions and style for Java snippets across all docs (see below).

Documentation

This PR contains docs update only.


Changes

  • Added compiler:compile execution in docs to compile the snippets
  • Fix snippets indentations (E.g. XML for dependencies)
  • Fix multiple XML roots in snippets (wrap with a parent)
  • Fix comments used for annotation in YAML snippets
  • Fix IntelliJ warnings and errors to make them useful (now that the noise of the inlined Java snippets is removed)
  • Fix typos reported by IntelliJ spell checking
  • Break lines over 140 characters
  • Use hocon as the language type for JSON snippets with annotation (syntax: // <1>)
  • Normalize(-ish) the request/response snippets ; split out the JSON responses into dedicated code blocks
  • Add the fit role to many images

New conventions

  • 1:1 between .adoc and .java (one "Snippets" class for each document)
  • package layout mirrors src/main/asciidoc (base package io.helidon.docs)
  • classes are named using the camel case name equivalent of the document + Snippets suffix (E.g. reactive-messaging.adoc -> ReactiveMessagingSnippets.java
  • Snippets are named snippet_{index} where index is the snippet index in the document (starting at index 1)
  • If the snippet is composed of statements, it is enclosed with a method void snippet_{index} {}
  • If the snippet is a class (I.e class, record, interface, enum) ; and the name conflicts with any other snippet in the class, the snippet is enclosed in a class named Snippet{Index}
  • If the snippet has unresolved references, they can be stubbed, with method parameters (if enclosed with a method), or by adding stubs at the top of the file (E.g. records, classes, constants etc.)
  • Annotation comments (E.g. // <1>) are not padded ; (don't bother aligning them ; it is not something that we can consistently maintain) ; instead they should be separated by a single space character

Changes in snippets

  • imports are removed from snippets, this simplifies the maintenance of the snippets (note that we should address this in the future and provide a way to see the imports of snippets in the docs)
  • var keyword is preferred to improve readability unless the type matters for the understanding of the snippet

@romain-grecourt romain-grecourt added docs 4.x Version 4.x labels Jan 25, 2024
@romain-grecourt romain-grecourt added this to the 4.0.4 milestone Jan 25, 2024
@romain-grecourt romain-grecourt self-assigned this Jan 25, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. labels Jan 25, 2024
tjquinno

This comment was marked as resolved.

@romain-grecourt

This comment was marked as resolved.

@tjquinno

This comment was marked as resolved.

@barchetta barchetta modified the milestones: 4.0.4, 4.1.0 Jan 26, 2024
@romain-grecourt romain-grecourt changed the title 4.x - Externalize and compile documentation java snippets - part 1 4.x - Externalize and compile documentation java snippets Feb 1, 2024
@romain-grecourt romain-grecourt force-pushed the docs-compile-java-snippets branch from ba1baeb to 1537c75 Compare February 13, 2024 03:59
@romain-grecourt romain-grecourt force-pushed the docs-compile-java-snippets branch from 1537c75 to eac273c Compare February 13, 2024 04:04
tomas-langer
tomas-langer previously approved these changes Feb 14, 2024
Copy link
Member

@tomas-langer tomas-langer left a comment

Choose a reason for hiding this comment

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

This brings in a much needed validation of code snippets that will make it easier to keep documentation up to date for our future (and current) releases.
Thanks!

- [listing] -> [source, text]
- typos ; hyphenated words reported by IntelliJ
- MP config snippets
- Fix properties snippets (use = instead of : for the key-value separator)
- Some normalization of curl request / response (JSON response as a separate block with a nested title 'JSON response')
- Add fit role to many images
- Fix XML indentation
Copy link
Member

@barchetta barchetta left a comment

Choose a reason for hiding this comment

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

Great work!

@romain-grecourt romain-grecourt merged commit 911057e into helidon-io:main Feb 15, 2024
12 checks passed
hrstoyanov pushed a commit to hrstoyanov/helidon that referenced this pull request Feb 23, 2024
…#8294)

Externalize and compile docs java snippets.
Introduce conventions and style for Java snippets across all docs (see helidon-io#8294)
@barchetta barchetta modified the milestones: 4.1.0, 4.0.6 Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x docs OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
Archived in project
4 participants