Add README.adoc processor
This commit is contained in:
41
README.adoc
Normal file
41
README.adoc
Normal file
@@ -0,0 +1,41 @@
|
||||
// Do not edit this file (go instead to src/main/asciidoc)
|
||||
|
||||
Spring Boot command line features for
|
||||
[Spring Cloud](https://github.com/spring-cloud).
|
||||
|
||||
|
||||
== Installation
|
||||
|
||||
To install, make
|
||||
sure you have
|
||||
[Spring Boot CLI](https://github.com/spring-projects/spring-boot)
|
||||
(1.1.x with x>=5):
|
||||
|
||||
$ spring version
|
||||
Spring CLI v1.1.5.RELEASE
|
||||
|
||||
E.g. for GVM users
|
||||
|
||||
```
|
||||
$ gvm install springboot 1.1.5.RELEASE
|
||||
$ gvm use springboot 1.1.5.RELEASE
|
||||
```
|
||||
|
||||
then get the install command plugin (backported from Boot 1.2.0):
|
||||
|
||||
```
|
||||
$ wget http://dl.bintray.com/dsyer/generic/install-0.0.1.jar
|
||||
```
|
||||
|
||||
install it in the Spring Boot CLI, e.g. with GVM (MacOS users that rely on brew might have to find the `/lib` directory by scanning `brew info springboot`):
|
||||
|
||||
```
|
||||
$ cp install-0.0.1.jar ~/.gvm/springboot/1.1.5.RELEASE/lib
|
||||
```
|
||||
|
||||
and finally install the Spring Cloud plugin:
|
||||
|
||||
```
|
||||
$ mvn install
|
||||
$ spring install org.springframework.cloud:spring-cloud-cli:1.0.0.BUILD-SNAPSHOT
|
||||
```
|
||||
32
pom.xml
32
pom.xml
@@ -43,4 +43,36 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jruby</groupId>
|
||||
<artifactId>jruby-complete</artifactId>
|
||||
<version>1.7.12</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>readme</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<inherited>false</inherited>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<java classname="org.jruby.Main" failonerror="yes">
|
||||
<arg value="${basedir}/src/main/ruby/generate_readme.sh" />
|
||||
<arg value="${basedir}/README.adoc" />
|
||||
</java>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
5
src/main/asciidoc/README.adoc
Normal file
5
src/main/asciidoc/README.adoc
Normal file
@@ -0,0 +1,5 @@
|
||||
include::intro.adoc[]
|
||||
|
||||
== Installation
|
||||
|
||||
include::install.adoc[]
|
||||
@@ -1,5 +1,4 @@
|
||||
Spring Boot command line features for
|
||||
[Spring Cloud](https://github.com/spring-cloud). To install, make
|
||||
To install, make
|
||||
sure you have
|
||||
[Spring Boot CLI](https://github.com/spring-projects/spring-boot)
|
||||
(1.1.x with x>=5):
|
||||
3
src/main/asciidoc/intro.adoc
Normal file
3
src/main/asciidoc/intro.adoc
Normal file
@@ -0,0 +1,3 @@
|
||||
Spring Boot command line features for
|
||||
[Spring Cloud](https://github.com/spring-cloud).
|
||||
|
||||
@@ -1,34 +1,7 @@
|
||||
Spring Boot command line features for
|
||||
[Spring Cloud](https://github.com/spring-cloud). To install, make
|
||||
sure you have
|
||||
[Spring Boot CLI](https://github.com/spring-projects/spring-boot)
|
||||
(1.1.x with x>=5):
|
||||
= Spring Boot CLoud CLI
|
||||
|
||||
$ spring version
|
||||
Spring CLI v1.1.5.RELEASE
|
||||
include::intro.adoc[]
|
||||
|
||||
E.g. for GVM users
|
||||
== Installation
|
||||
|
||||
```
|
||||
$ gvm install springboot 1.1.5.RELEASE
|
||||
$ gvm use springboot 1.1.5.RELEASE
|
||||
```
|
||||
|
||||
then get the install command plugin (backported from Boot 1.2.0):
|
||||
|
||||
```
|
||||
$ wget http://dl.bintray.com/dsyer/generic/install-0.0.1.jar
|
||||
```
|
||||
|
||||
install it in the Spring Boot CLI, e.g. with GVM (MacOS users that rely on brew might have to find the `/lib` directory by scanning `brew info springboot`):
|
||||
|
||||
```
|
||||
$ cp install-0.0.1.jar ~/.gvm/springboot/1.1.5.RELEASE/lib
|
||||
```
|
||||
|
||||
and finally install the Spring Cloud plugin:
|
||||
|
||||
```
|
||||
$ mvn install
|
||||
$ spring install org.springframework.cloud:spring-cloud-cli:1.0.0.BUILD-SNAPSHOT
|
||||
```
|
||||
include::install.adoc[]
|
||||
|
||||
10
src/main/ruby/generate_readme.sh
Executable file
10
src/main/ruby/generate_readme.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
base_dir = File.join(File.dirname(__FILE__),'../../..')
|
||||
src_dir = File.join(base_dir, "/src/main/asciidoc")
|
||||
require File.join(File.dirname(__FILE__), 'readme.rb')
|
||||
|
||||
options = {}
|
||||
ARGV.length > 0 and options[:to_file] = ARGV[0]
|
||||
|
||||
SpringCloud::Build.render_file("#{src_dir}/README.adoc", options)
|
||||
51
src/main/ruby/readme.rb
Normal file
51
src/main/ruby/readme.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
module SpringCloud
|
||||
module Build
|
||||
|
||||
IncludeDirectiveRx = /^\\?include::([^\[]+)\[(.*?)\]$/
|
||||
|
||||
class << self
|
||||
|
||||
def process_include out, src, target, attrs
|
||||
unless target.start_with?('/')
|
||||
target = File.new(File.join(src, target))
|
||||
else
|
||||
target = File.new(target)
|
||||
end
|
||||
target.each do |line|
|
||||
self.process(out, File.dirname(target), line)
|
||||
end
|
||||
end
|
||||
|
||||
def process out, src, line
|
||||
if ((escaped = line.start_with?('\\include::')) || line.start_with?('include::')) && (match = IncludeDirectiveRx.match(line))
|
||||
if escaped
|
||||
out << line[1..-1]
|
||||
else
|
||||
self.process_include out, src, match[1], match[2].strip
|
||||
end
|
||||
else
|
||||
out << line
|
||||
end
|
||||
end
|
||||
|
||||
def render_file file, options = {}
|
||||
|
||||
srcDir = File.dirname(file)
|
||||
out = ["// Do not edit this file (go instead to src/main/asciidoc)\n","\n"]
|
||||
File.new(file).each do |line|
|
||||
self.process(out, srcDir, line)
|
||||
end
|
||||
|
||||
unless options[:to_file]
|
||||
puts out
|
||||
else
|
||||
writer = File.new(options[:to_file],'w+')
|
||||
out.each { |line| writer.write(line) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user