Commit Graph

34 Commits

Author SHA1 Message Date
Alexander Schwartz
2cf5919632 Provide context when logging warnings in operation macro
See gh-699
2020-11-13 14:50:29 +00:00
Andy Wilkinson
ed5921fe83 Ensure that UTF-8 is used to read and write snippets in operation macro
Fixes gh-696
2020-09-14 14:40:56 +01:00
Andy Wilkinson
a1a2271133 Test Asciidoctor extension against AsciidoctorJ 2.2, 2.3, and 2.4
Closes gh-694
2020-09-02 11:13:06 +01:00
Andy Wilkinson
bb7aecbfe5 Fix problem with operation block macro when using leveloffset
Previously, when a document had a leveloffset attribute this was
included in the attributes used when loading a snippet in the
operation block macro. This could lead to warnings about section
titles being out of sequence as the level used for the title did not
take the leveloffset into consideration.

This commit clones the documents attributes and removes any
leveloffset attribute before loading a snippet. This removes the
need for the leveloffset to be considered when loading a snippet
fragment. As before, the level of each block in the fragment loaded
from snippet is then set prior to adding the block to the main
document. This takes the leveloffset into consideration.

Closes gh-649
2019-10-17 15:40:52 +01:00
Andy Wilkinson
816987824c Ensure that spring-restdocs-asciidoctor pom contains name and description 2019-09-30 09:04:09 +01:00
Andy Wilkinson
8624a33ff5 Polish "Prevent unwanted incrementing of section number in operation macro"
See gh-638
2019-09-19 11:10:57 +01:00
Alexander Schwartz
1d911367d6 Prevent unwanted incrementing of section number in operation macro
See gh-638
2019-09-19 10:45:43 +01:00
Andy Wilkinson
66787cd3a5 Broaden compatibility testing for Asciidoctor 2.x
Closes gh-630
2019-09-13 12:58:11 +01:00
Andy Wilkinson
9de06a36d2 Polish "Avoid warnings when parsing AsciiDoc sub-content in Asciidoctor.load"
See gh-628
2019-08-30 12:30:45 +01:00
Andy Wilkinson
cc22dbfe26 Merge branch '1.2.x' 2019-08-30 11:20:34 +01:00
Andy Wilkinson
508b3d6593 Upgrade to Spring Java Format 0.0.15 2019-08-30 11:07:04 +01:00
Andy Wilkinson
619847582a Reuse document's attributes when loading snippet content
Previously, when adding blocks for the snippets' content, the
operation macro would call Asciidoctor to load the content with
attributes that only included the projectdir. This resulted in a
failure in environments that did not set the projectdir and instead
relied on another attribute, such as gradle-projectdir as used by
the latest versions of the Asciidoctor Gradle plugin.

This commit updates the macro to reuse all of the main document's
attributes when loading the snippets' content, thereby ensuring that
any attributes available in the main document are also available
during snipppet processing.

Closes gh-624
2019-06-20 10:35:33 +01:00
Andy Wilkinson
136df15fad Ensure that jars to be merged are built before merging them
See gh-581
2019-06-18 12:51:34 +01:00
Andy Wilkinson
ff18f8034d Add AsciidoctorJ 1.6 and 2.0 compatibility
AsciidoctorJ 1.6 is not backwards compatible with AsciidoctorJ 1.5
and AsciidoctorJ 2.0 is not backwards compatible with AsciidoctorJ 1.6
or 1.5. The backwards incompatibilities are such that they cannot be
worked around using reflection so code needs to be compiled against
each of the three versions. To this end, this commit splits
spring-restdocs-asciidoctor into several separate modules:

1. spring-restdocs-asciidoctor-support
2. spring-restdocs-asciidoctor-1.5
3. spring-restdocs-asciidoctor-1.6
4. spring-restdocs-asciidoctor-2.0

spring-restdocs-asciidoctor-support contains support code that is not
tied to a specific version of AsciidoctorJ and can be used with
1.5, 1.6 and 2.0. The other three modules contain code that is
specific to a particular version of AsciidoctorJ. Each
version-specific module uses class names that are unique across all
three modules and is written in such a way that they will back off
when used in an environment with a different version of AsciidoctorJ.
The existing spring-restdocs-asciidoctor module has been modified to
merge the version specific jars and the support jar together into a
single jar that supports AsciidoctorJ 1.5, 1.6, and 2.0.

The above-described changes should allow users to depend upon
spring-restdocs-asciidoctor as before and to now be able to use
AsciidoctorJ 1.5, 1.6, or 2.0.

Closes gh-581
2019-06-18 12:28:36 +01:00
Andy Wilkinson
00da0834df Merge branch '1.2.x' 2019-06-18 12:15:56 +01:00
Andy Wilkinson
76a89cf658 Upgrade to AsciidoctorJ 1.5.8.1
Closes gh-621
2019-06-18 12:14:15 +01:00
Andy Wilkinson
09a4323ed5 Merge branch '1.2.x' 2019-03-19 11:42:23 +00:00
Andy Wilkinson
3282a798cb Merge branch '1.1.x' into 1.2.x 2019-03-19 11:35:06 +00:00
Andy Wilkinson
b694298720 Prepare for Asciidoctor Gradle Plugin 2.0 by looking for gradle-projectdir
Closes gh-562
2018-11-21 15:17:51 +00:00
Andy Wilkinson
7431426cf3 Update tests to use AssertJ
Closes gh-537
2018-08-08 11:22:57 +01:00
Andy Wilkinson
0b0c9e1cc4 Perform attribute substitution on operation macro's target
Closes gh-491
2018-03-27 15:24:00 +01:00
Andy Wilkinson
ba327f1e9a Ensure that all nodes for a snippet refer to main document
Previously, when the operation block macro rendered the fragment
for a snippet, every top-level block in the fragment had its parent
set. Setting the parent has the side-effect of also setting the
block's document to be that of its parent. This meant that every
top-level block's document referred to the main document, but any
descendents were left with their document referring to the fragment
document. This did not cause a problem with the HTML backend (which
does not consider a block's document) but the PDF backend does
consider a block's document resulting in the descendents being
omitted from the generated PDF.

This commit updates the operation block macro to set the parent of
every block in the fragment to its correct value. This has the
side-effect of causing the block to update its document reference to
point to the main document.

Closes gh-396
2017-05-30 13:11:01 +01:00
Andy Wilkinson
d1424c90ca Ensure that provided dependency on asciidoctorj appears in generated pom
Closes gh-385
2017-04-24 15:58:17 +01:00
Andy Wilkinson
a4d2fc39d8 Allow snippet section titles to be customized using document attributes
Closes gh-363
2017-03-08 10:41:54 +00:00
Andy Wilkinson
86f6dbab9c Specify an ID for each section created by the operation macro
Closes gh-364
2017-03-08 09:45:02 +00:00
Andy Wilkinson
40fc211d9e Polishing 2017-03-07 18:42:01 +00:00
Andy Wilkinson
6f7be570f7 Another attempt at fixing OperationBlockMacroTests on Windows
It appears that Asciidoctor uses \n on all platforms but when the
expected content is read in on Windows it uses \r\n as the line
endings are being changed when Git performs the clone.
2017-03-07 18:37:27 +00:00
Andy Wilkinson
d3fdd0bef7 Fix OperationBlockMacroTests on Windows 2017-03-07 18:30:00 +00:00
Andy Wilkinson
826e0a5dec Polish “Provide a block macro for including an operation's snippets”
- Copy snippets used in the tests in @BeforeClass rather than using
   Gradle so that the tests can be run easily in an IDE
 - Address problems in operation_block_macro.rb reported by Rubocop
 - Rename new test class to more closely match the name of the Ruby
   class that it’s testing
 - Gracefully handle a missing operation
 - Align behaviour when an operation or snippet is missing more closely
   with Asciidoctor’s behaviour when an include references a missing
   file
 - Use kebab-case rather than snake_case for new test resources
 - Update the documentation to describe the new macro

See gh-354
Closes gh-323
2017-03-07 17:27:29 +00:00
Gerrit Meier
18b559a839 Provide a block macro for including an operation's snippets
See gh-323
Closes gh-354
2017-03-07 16:46:57 +00:00
Andy Wilkinson
60211dab86 Polishing
- Pass attributes into RequestPartFieldsSnippet
 - Add missing package.info.java for new asciidoctor package
2016-10-25 16:10:58 +01:00
Andy Wilkinson
49596df0f3 Make snippet directory resolution more robust
The previous approach had (at least) two problems:

 - A Gradle build run from a directory that also contains a pom.xml
   would result in the resolver incorrectly identifing that Maven was
   being used
 - A Maven build run from a directory that did not could a pom and
   that used -f to provide the path to a pom would result in the
   resolver incorretly indentifying that Gradle was being used

With this commit, the resolver now uses the presence of the maven.home
system property to identify that Maven is being used. When Maven
is being used, rather than looking for a pom.xml in the working
directory, the resolver now locates the pom.xml by searching up the
directory hierarchy from the docdir.

Closes gh-297
2016-10-22 21:58:11 +01:00
Andy Wilkinson
c13b7d03f5 Fix DefaultAttributesPreprocessorTests on Windows 2016-10-21 23:26:18 +01:00
Andy Wilkinson
319bd139fc Polish contribution and rework to use default attribute rather than macro
Rather than introducing a custom macro, this commit opts to implicitly
configure the snippets attribute instead. The attribute is configured
will the path into which snippets are generated, relative to the
directory that contains the Asciidoctor document that is being
rendered.

The samples and documentation have been updated to use the new
spring-restdocs-asciidoctor module and the implicitly configured
snippets attribute.

Closes gh-297
2016-10-21 22:42:11 +01:00