Here’s how to include the code from the first commit (revision fdc094c892b
) to lib/asciidoctor-git-include.rb
:
.lib/asciidoctor-git-include.rb
[source,ruby]
----
include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;11..24]
----
The above code, when embedded in an asciidoc, will render selected lines from the file in the specified revision:
link:git@lib/asciidoctor-git-include.rb[role=include]
The revision
is optional (HEAD
is the default) as well as the lines
.
Include the diff from the second commit (revision d64d85e37b4
) to its preceding revision of lib/asciidoctor-git-include.rb
:
.Changes introduced in d64d85e37b4
[source,patch]
----
include::git@lib/asciidoctor-git-include.rb[revision=d64d85e37b4,diff,lines=7..17]
----
The above code will render:
link:git@lib/asciidoctor-git-include.rb[role=include]
Include the diff between two revisions (e3b17ded3
and d64d85e37b4
) of lib/asciidoctor-git-include.rb
:
.Changes between e3b17ded3 and d64d85e37b4
[source,patch]
----
include::git@lib/asciidoctor-git-include.rb[revision=e3b17ded3,diff=d64d85e37b4,lines=6..18]
----
The above code will render:
link:git@lib/asciidoctor-git-include.rb[role=include]
The repository
attribute can be given to point to an external repository location.
.lib/asciidoctor-git-include.rb
[source,ruby]
----
include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;24,repository=.]
----
The above code will render:
link:git@lib/asciidoctor-git-include.rb[role=include]
The example uses the current repository location for practical reasons, but any local filesystem location should work.
Clone the repository.
git clone https://github.com/jakzal/asciidoctor-git-include.git
cd asciidoctor-git-include
Next, choose whether you’d like to use Docker or build the gem directly on your OS. Continue with one of the sections that follow.
-
Build the Docker image with the
asciidoctor-git-include
extension. Thedocker build
command should be run at the top level directory of this project.Building the Docker imagedocker build -t jakzal/asciidoctor .
-
Build the page.
Building the page with Dockerdocker run -t --rm --name docs -v $(pwd):/project -w /project jakzal/asciidoctor \ asciidoctor -r asciidoctor-git-include examples/index.adoc -o examples/index.html
-
Open the generated
examples/index.html
in a browser.
-
Install asciidoctor on your system.
gem install asciidoctor rouge
-
Build the extension gem and install it on your system.
Building and installing the gemgem build asciidoctor-git-include.gemspec gem install asciidoctor-git-include-*.gem
This will the development version. To install the version published to ruby gems run the following command instead:
gem install asciidoctor-git-include
-
Build the page
Building the page with asciidoctorasciidoctor -r asciidoctor-git-include examples/index.adoc -o examples/index.html
-
Open the generated
examples/index.html
in a browser.