Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"-Djava.util.logging.config.file=src/test/resources/logging.properties"
]
},
"asciidoc.antora.enableAntoraSupport": false
"asciidoc.antora.showEnableAntoraPrompt": false
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _[Place a screenshot of a tracing report generated using this plugin here]_
## Project Information

[![Build](https://github.com/itsallcode/openfasttrace-asciidoc-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/itsallcode/openfasttrace-asciidoc-plugin/actions/workflows/build.yml)
[![Maven Central Version](https://img.shields.io/maven-central/v/org.itsallcode/openfasttrace-asciidoc-plugin)](https://search.maven.org/artifact/org.itsallcode/openfasttrace-asciidoc-plugin)
[![Maven Central Version](https://img.shields.io/maven-central/v/org.itsallcode/openfasttrace-asciidoc-plugin)](https://central.sonatype.com/artifact/org.itsallcode/openfasttrace-asciidoc-plugin)

Sonarcloud status:

Expand Down Expand Up @@ -64,7 +64,7 @@ For more detailed information on how to use OpenFastTrack with AsciiDoc Plugin,

The OpenFastTrace AsciiDoc Plugin is supplied as a Java Archive (JAR) which can be obtained from:

* [Maven Central](#)
* [Maven Central](https://central.sonatype.com/artifact/org.itsallcode/openfasttrace-asciidoc-plugin)
* [GitHub](https://github.com/itsallcode/openfasttrace-asciidoc-plugin/releases)

More details about adding the plugin to an existing establishment are outlined in the [developer guide](doc/developer_guide.md).
Expand Down
1 change: 1 addition & 0 deletions doc/changes/changes_0.3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ We upgraded the OFT dependency to version 4.8.0.
## Refactoring

* Updated OFT to 4.8.0
* Updated asciidoctorj dependency to 3.0.1
2 changes: 1 addition & 1 deletion doc/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The list below shows all build time dependencies in alphabetical order. Note tha
| Dependency | Purpose | License |
| ---------------------------------------------------------------------------- | --------------------------------------- | ----------------------------- |
| [Hamcrest Auto Matcher](https://github.com/itsallcode/hamcrest-auto-matcher) | Speed-up for building Hamcrest matchers | GNU General Public License V3 |
| [JUnit](https://junit.org/junit5) | Unit testing framework | Eclipse Public License 1.0 |
| [JUnit](https://docs.junit.org/current/user-guide/) | Unit testing framework | Eclipse Public License 1.0 |
| [Mockito](https://github.com/mockito/mockito) | Mocking framework | MIT License |

### Runtime Dependencies
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<oft.version>4.8.0</oft.version>
<jacoco.version>0.8.14</jacoco.version>
<!-- Upgrading to 3.0.1 causes test failures, see https://github.com/itsallcode/openfasttrace-asciidoc-plugin/issues/19 -->
<asciidoctor.version>3.0.0</asciidoctor.version>
<asciidoctor.version>3.0.1</asciidoctor.version>
<sonar.organization>itsallcode</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ class AsciiDocImporter implements Importer

private static final String CONTENT_MODEL_SIMPLE = "simple";

private static final String KEY_ROLE = "role";
private static final String NODE_NAME_PARAGRAPH = "paragraph";

private static final String ROLE_COMMENT = ":comment";
private static final String ROLE_DESCRIPTION = ":description";
private static final String ROLE_RATIONALE = ":rationale";

private static final String ROLE_NAME_SPECITEM = "specitem";
private static final String ROLE_COMMENT = "comment";
private static final String ROLE_DESCRIPTION = "description";
private static final String ROLE_RATIONALE = "rationale";
private static final String ROLE_SPECITEM = "specitem";

private static final Logger LOG = Logger.getLogger(AsciiDocImporter.class.getName());

Expand Down Expand Up @@ -79,6 +78,8 @@ private Location getLocation(final StructuralNode block)

private Optional<String> getStringContent(final StructuralNode node)
{
LOG.finest(() -> "getting content for node [content model: %s, name: %s, location: %s]"
.formatted(node.getContentModel(), node.getNodeName(), getLocation(node)));
switch (node.getContentModel())
{
case CONTENT_MODEL_SIMPLE:
Expand Down Expand Up @@ -139,38 +140,52 @@ private void processSpecificationItemTags(final StructuralNode block)
// [impl->dsn~adoc-specification-item-description~1]
private void processSpecificationItemDescription(final StructuralNode block)
{
final Optional<StructuralNode> descriptionBlock = block.findBy(Map.of(KEY_ROLE, ROLE_DESCRIPTION)).stream()
final Optional<StructuralNode> descriptionBlock = block.getBlocks().stream()
.filter(node -> !ROLE_RATIONALE.equals(node.getRole()))
.filter(node -> !ROLE_COMMENT.equals(node.getRole()))
.filter(node -> ROLE_DESCRIPTION.equals(node.getRole())
|| NODE_NAME_PARAGRAPH.equals(node.getNodeName()))
.findFirst();
descriptionBlock
.or(() -> block.getBlocks().stream()
.filter(node -> !"rationale".equals(node.getRole()) && !"comment".equals(node.getRole()))
.findFirst())
.flatMap(this::getStringContent)
.ifPresent(listener::appendDescription);

descriptionBlock.flatMap(this::getStringContent)
.ifPresent(description -> {
LOG.finest(() -> "adding description to spec item: %s".formatted(description));
listener.appendDescription(description);
});
}

// [impl->dsn~adoc-specification-item-rationale~1]
private void processSpecificationItemRationale(final StructuralNode block)
{
block.findBy(Map.of(KEY_ROLE, ROLE_RATIONALE)).stream().findFirst()
block.getBlocks().stream()
.filter(node -> ROLE_RATIONALE.equals(node.getRole()))
.findFirst()
.flatMap(this::getStringContent)
.ifPresent(listener::appendRationale);
.ifPresent(rationale -> {
LOG.finest(() -> "adding rationale to spec item: %s".formatted(rationale));
listener.appendRationale(rationale);
});
}

// [impl->dsn~adoc-specification-item-comment~1]
private void processSpecificationItemComment(final StructuralNode block)
{
block.findBy(Map.of(KEY_ROLE, ROLE_COMMENT)).stream().findFirst()
block.getBlocks().stream()
.filter(node -> ROLE_COMMENT.equals(node.getRole()))
.findFirst()
.flatMap(this::getStringContent)
.ifPresent(listener::appendComment);
.ifPresent(comment -> {
LOG.finest(() -> "adding comment to spec item: %s".formatted(comment));
listener.appendComment(comment);
});
}

private void processSpecificationItemBlock(final String sid, final StructuralNode block)
{
final SpecificationItemId specItemId = new SpecificationItemId.Builder(sid).build();
final Location location = getLocation(block);
LOG.fine(() -> String.format("adding specification item [ID: %s, location: %s]", specItemId,
location));
LOG.fine(() -> String.format("adding specification item [ID: %s, block name: %s, location: %s]", specItemId,
block.getNodeName(), location));

this.listener.beginSpecificationItem();
this.listener.setId(specItemId);
Expand Down Expand Up @@ -220,8 +235,8 @@ private void processForwardingBlock(final String skippedType, final StructuralNo
// [impl->dsn~adoc-artifact-forwarding-notation~1]
private void processSpecificationItem(final StructuralNode block)
{
LOG.fine(() -> String.format("found specitem block [id: %s]",
block.getId()));
LOG.fine(() -> String.format("found specitem block [id: %s, name: %s]",
block.getId(), block.getNodeName()));

Optional.ofNullable(block.getAttribute(ATTRIBUTE_OFT_SID))
.filter(String.class::isInstance)
Expand All @@ -248,7 +263,7 @@ private void processDocument(final Document document)

private void processBlock(final StructuralNode block)
{
if (block.hasRole(ROLE_NAME_SPECITEM))
if (block.hasRole(ROLE_SPECITEM))
{
processSpecificationItem(block);
}
Expand Down Expand Up @@ -280,7 +295,7 @@ private void processTable(final Table table)
private Document parseAsciiDoc()
{
final Options options = Options.builder().sourcemap(true).build();
try (final Asciidoctor asciidoctor = Asciidoctor.Factory.create())
try (Asciidoctor asciidoctor = Asciidoctor.Factory.create())
{
if (this.file != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void testImporterIgnoresSpecItemWithoutId(final String content)
@ValueSource(strings =
{
"""
# Spec
# Spec 1

[.specitem, oft-sid="dsn~detail-design~1", oft-depends="dsn~grand-design~1, arch~general-constraints~1", oft-needs="impl, utest", oft-covers="req~first-requirement~1, req~second-requirement~1", oft-tags="Priority1, OtherComponent"]
## A Requirement
Expand All @@ -79,7 +79,7 @@ void testImporterIgnoresSpecItemWithoutId(final String content)
A comment
""",
"""
# Spec
# Spec 2

[.specitem, oft-sid="dsn~detail-design~1", oft-depends="dsn~grand-design~1, arch~general-constraints~1", oft-needs="impl, utest", oft-covers="req~first-requirement~1, req~second-requirement~1", oft-tags="Priority1, OtherComponent"]
## A Requirement
Expand All @@ -94,7 +94,7 @@ void testImporterIgnoresSpecItemWithoutId(final String content)
A comment
""",
"""
# Spec
# Spec 3

.A Requirement
[.specitem, oft-sid="dsn~detail-design~1", oft-depends="dsn~grand-design~1, arch~general-constraints~1", oft-needs="impl, utest", oft-covers="req~first-requirement~1, req~second-requirement~1", oft-tags="Priority1, OtherComponent"]
Expand All @@ -110,7 +110,7 @@ void testImporterIgnoresSpecItemWithoutId(final String content)
====
""",
"""
# Spec
# Spec 4

.A Requirement
[.specitem, oft-sid="dsn~detail-design~1", oft-depends="dsn~grand-design~1, arch~general-constraints~1", oft-needs="impl, utest", oft-covers="req~first-requirement~1, req~second-requirement~1", oft-tags="Priority1, OtherComponent"]
Expand Down
Loading