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

AsciiDoc code snippets in documentation #335

Closed
Michael1993 opened this issue Sep 8, 2020 · 4 comments · Fixed by #334
Closed

AsciiDoc code snippets in documentation #335

Michael1993 opened this issue Sep 8, 2020 · 4 comments · Fixed by #334

Comments

@Michael1993
Copy link
Member

Demonstrated in #334, we can use a neat built-in feature of AsciiDoc to include live code examples in our .adoc documentation.

The proper way to utilize this feature warrants a discussion.

@Bukama
Copy link
Member

Bukama commented Oct 6, 2020

To copy my concerns from the draft into the discussion:

@Michael1993
Copy link
Member Author

Michael1993 commented Oct 6, 2020

  • How do you limit to (about) 60 chars per line?

We could use Java::Geci to format code snippets before they are inserted into the documentation. Maybe we can tell spotless to consider snippets as special cases. Maybe AsciiDoc supports reformatting? I'll look into our options and get back to you on that.

  • I'm not sure if this is helpful. We often make comments in the documentation example but not in the test cases.

Yes, this is certainly a drawback. Some ideas about what we could do to counteract this problem:

  • We could put the comments in the actual tests so they get copied with the snippet
  • We could put the content of the comments around the snippet (e.g.: instead of saying "here we call this because", we write after the test "notice how there we called X. We did this because...")

We might decide that the fruit ain't worth the squeeze, but we won't know for sure unless we try squeezing first.

@Bukama Bukama added this to To do in Exploring Io Oct 27, 2020
@Bukama Bukama moved this from To do to In progress in Exploring Io Oct 27, 2020
@Bukama
Copy link
Member

Bukama commented Dec 9, 2020

@Michael1993 Could you summarize your yesterdays question and the answer to it please.

@Michael1993
Copy link
Member Author

Michael1993 commented Dec 9, 2020

The question was: "How should we proceed with this, without polluting our tests with 'noisy demo tests'?". The answer is basically what Nicolai wrote on the PR.

@nipafx wrote on Sep 29:

I really like this approach to showing code snippets because we can always be sure that they actually work. @Bukama's concerns are valid, though. Tests and code snippets have very different concerns and we should hence separate them.

I propose to create a new source set demo (as src/demo/java) and put all the demos there. They must be written as proper tests, so we can execute them during the build, but they can be written and styled according to the documentation's needs.

If possible, we could even use Spotless to limit line length to 60 chars (if we can have different configurations for different folders - I think we already had that request once).

We agreed that this was a good approach and we should play around with it in a PR. I'll go ahead when I have the time.

@Michael1993 Michael1993 self-assigned this Dec 9, 2020
@nipafx nipafx added this to Improve in Up for grabs... Apr 13, 2021
@nipafx nipafx added ⚙️ component: Pioneer Issues about Pioneer own things (e.g. utils) and removed ⚙️ component: Jupiter Issues coming from (internal/official) Jupiter features etc. labels May 5, 2021
@Michael1993 Michael1993 removed this from Improve / Discuss in Up for grabs... May 27, 2021
Exploring Io automation moved this from In progress to Done Feb 19, 2022
nipafx pushed a commit that referenced this issue Feb 19, 2022
Code snippets in the documentation files in `docs` are just text and
thus run the risk of getting outdated when APIs evolve or
implementations change their behavior. To address that, we now use
Asciidoc's capability to include tagged regions from external
files[1] that are compiled and tested by the build. These files'
primary purpose is to demonstrate features (not to test them) and so
they are placed in a new source set `src/demojava`.

[1]: https://docs.asciidoctor.org/asciidoc/latest/directives/include-tagged-regions/

Related to junit-pioneer/junit-pioneer.github.io#33
Closes: #335
PR: #334
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants