Skip to content

Commit 1c54ac2

Browse files
committed
Add main examples to the documentation
1 parent 805c61d commit 1c54ac2

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

examples/index.adoc

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,94 @@ v1.0.0
77
:data-uri:
88
:source-highlighter: rouge
99

10+
== Including a file from git
11+
12+
Here's how to include the code from the first commit (revision `fdc094c892b`) to `lib/asciidoctor-git-include.rb`:
13+
14+
[source,asciidoc]
15+
....
16+
.lib/asciidoctor-git-include.rb
17+
[source,ruby]
18+
----
19+
\include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;11..24]
20+
----
21+
....
22+
23+
The above code, when embedded in an asciidoc, will render selected lines from the file in the specified revision:
24+
25+
.lib/asciidoctor-git-include.rb
26+
[source,ruby]
27+
----
28+
include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;11..24]
29+
----
30+
31+
The `revision` is optional (`HEAD` is the default) as well as the `lines`.
32+
33+
== Including a diff from git
34+
35+
Include the diff from the second commit (revision `d64d85e37b4`) to its preceding revision of `lib/asciidoctor-git-include.rb`:
36+
37+
[source,asciidoc]
38+
....
39+
.Changes introduced in d64d85e37b4
40+
[source,patch]
41+
----
42+
\include::git@lib/asciidoctor-git-include.rb[revision=d64d85e37b4,diff,lines=7..17]
43+
----
44+
....
45+
46+
The above code will render:
47+
48+
.Changes introduced in d64d85e37b4
49+
[source,patch]
50+
----
51+
include::git@lib/asciidoctor-git-include.rb[revision=d64d85e37b4,diff,lines=7..17]
52+
----
53+
54+
== Including a diff between any two revisions
55+
56+
Include the diff between two revisions (`e3b17ded3` and `d64d85e37b4`) of `lib/asciidoctor-git-include.rb`:
57+
58+
[source,asciidoc]
59+
....
60+
.Changes between e3b17ded3 and d64d85e37b4
61+
[source,patch]
62+
----
63+
\include::git@lib/asciidoctor-git-include.rb[revision=e3b17ded3,diff=d64d85e37b4,lines=6..18]
64+
----
65+
....
66+
67+
The above code will render:
68+
69+
.Changes between e3b17ded3 and d64d85e37b4
70+
[source,patch]
71+
----
72+
include::git@lib/asciidoctor-git-include.rb[revision=e3b17ded3,diff=d64d85e37b4,lines=6..18]
73+
----
74+
75+
== Including code or diff from a different repository
76+
77+
The `repository` attribute can be given to point to an external repository location.
78+
79+
[source,asciidoc]
80+
....
81+
.lib/asciidoctor-git-include.rb
82+
[source,ruby]
83+
----
84+
\include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;24,repository=.]
85+
----
86+
....
87+
88+
The above code will render:
89+
90+
.lib/asciidoctor-git-include.rb
91+
[source,ruby]
92+
----
93+
include::git@lib/asciidoctor-git-include.rb[revision=fdc094c892b,lines=5;23,repository=.]
94+
----
95+
96+
The example uses the current repository location for practical reasons, but any local filesystem location should work.
97+
1098
== Building this page
1199

12100
Clone the repository.

0 commit comments

Comments
 (0)