vert-x3 / vertx-docgen

Documentation generation
Apache License 2.0
23 stars 11 forks source link

Fix indentation when processing external files (e.g. `.adoc`) #42

Closed michel-kraemer closed 1 month ago

michel-kraemer commented 1 month ago

Version

0.9.7

Context

While checking the 5.0.0-SNAPSHOT AsciiDoc docs on the website, I noticed that all inline code blocks are missing a leading space character.

Do you have a reproducer?

Here is an example from the vertx-hazelcast documentation (https://vertx.io/docs/vertx-hazelcast/java/).

The AsciiDoc source file contains the following code:

[source,xml,subs="+attributes"]
----
<dependency>
  <groupId>${maven.groupId}</groupId>
  <artifactId>${maven.artifactId}</artifactId>
  <version>${maven.version}</version>
</dependency>
----

Note the two space characters in lines 4-6.

However, the rendered code block on the website looks like this:

<dependency>
 <groupId>io.vertx</groupId>
 <artifactId>vertx-hazelcast</artifactId>
 <version>4.5.10</version>
</dependency>

Note that the first space character is missing.

It should look like this:

<dependency>
  <groupId>io.vertx</groupId>
  <artifactId>vertx-hazelcast</artifactId>
  <version>4.5.10</version>
</dependency>

Analysis

DocWriter strips off the first space character in each line because the processed javadoc contains an extra space (see inline comment). However, when processing external files such as Asciidoc sources (and not javadoc comments), trimming spaces is not needed.

Note that this issue does not affect included source files. This is because whenever a source file is included, DocWriter is put into literal mode. In this mode, it does not strip leading spaces.

I will submit a PR with a fix.