我可以包含完整的Greet.java
文件
public class Greet {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
从 asciidoc 文件中
== Hello Java
This is how one greets in Java:
[source,java]
.Greet.java
----
include::Greet.java
----
制作文件
但是假设我只想包含由标签分隔的代码的摘录。在上面的代码中,假设我只想包含该main
函数。
public class Greet {
// tag::helloMethod[]
public static void main(String[] args) {
System.out.println("Hello World!");
}
// end::helloMethod[]
}
和
== Hello Java
This is how one greets in Java:
[source,java]
.Greet.java
----
include::Greet.java[tags=helloMethod]
----
那只会产生:
你能建议一种只包括摘录的方法吗?我正在使用 asciidoc 8.6.9。