From 563df2a975f8c1aa0fce5044d2d3760e4ceda237 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 29 Sep 2014 14:12:56 +0100 Subject: [PATCH] Move README to src/main/asciidoc --- README.md => src/main/asciidoc/README.adoc | 42 +---------------- src/main/asciidoc/intro.adoc | 3 ++ src/main/asciidoc/spring-cloud-netflix.adoc | 3 +- src/main/ruby/generate_readme.sh | 10 ++++ src/main/ruby/readme.rb | 51 +++++++++++++++++++++ 5 files changed, 67 insertions(+), 42 deletions(-) rename README.md => src/main/asciidoc/README.adoc (56%) create mode 100644 src/main/asciidoc/intro.adoc create mode 100755 src/main/ruby/generate_readme.sh create mode 100644 src/main/ruby/readme.rb diff --git a/README.md b/src/main/asciidoc/README.adoc similarity index 56% rename from README.md rename to src/main/asciidoc/README.adoc index c4d76020..0f572dd3 100644 --- a/README.md +++ b/src/main/asciidoc/README.adoc @@ -1,44 +1,6 @@ -Ths project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. +include::intro.adoc[] -# Eureka Clients - -Example eureka client: - -``` -@Configuration -@ComponentScan -@EnableAutoConfiguration -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello world"; - } - - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).web(true).run(args); - } - -} - -``` - -(i.e. utterly normal Spring Boot app). Configuration is required to locate the Eureka server. Example: - -``` -eureka: - client: - serviceUrl: - defaultZone: http://localhost:8080/v2/ - default.defaultZone: http://localhost:8080/v2/ -``` - -The default application name, virtual host and non-secure port are taken from the `Environment` is -`${spring.application.name}`, `${spring.application.name}.mydomain.net` and `${server.port}` respectively. - -# TODO List +== TODO List - [x] Example front end app (currently in sandbox) - [x] Example back end service (currently in sandbox) diff --git a/src/main/asciidoc/intro.adoc b/src/main/asciidoc/intro.adoc new file mode 100644 index 00000000..c0b3f029 --- /dev/null +++ b/src/main/asciidoc/intro.adoc @@ -0,0 +1,3 @@ +This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration +and binding to the Spring Environment and other Spring programming model idioms. + diff --git a/src/main/asciidoc/spring-cloud-netflix.adoc b/src/main/asciidoc/spring-cloud-netflix.adoc index 5d55f739..bfe46afe 100644 --- a/src/main/asciidoc/spring-cloud-netflix.adoc +++ b/src/main/asciidoc/spring-cloud-netflix.adoc @@ -1,7 +1,6 @@ = Spring Cloud Netflix -This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration -and binding to the Spring Environment and other Spring programming model idioms. +include::intro.adoc[] == Service Discovery: Eureka Clients diff --git a/src/main/ruby/generate_readme.sh b/src/main/ruby/generate_readme.sh new file mode 100755 index 00000000..a6b3611a --- /dev/null +++ b/src/main/ruby/generate_readme.sh @@ -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) diff --git a/src/main/ruby/readme.rb b/src/main/ruby/readme.rb new file mode 100644 index 00000000..348507c2 --- /dev/null +++ b/src/main/ruby/readme.rb @@ -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 to #{file} instead)",""] + 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