Created
February 28, 2017 10:58
-
-
Save kornysietsma/205e7ea8490be255ce08381ca48302ab to your computer and use it in GitHub Desktop.
asciidoc bits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'asciidoctor-pdf', '>= 1.5.0.alpha.11' | |
gem 'asciidoctor' | |
gem 'asciidoctor-diagram', '~> 1.5.1' | |
gem 'rake' | |
gem 'coderay' | |
gem 'pygments.rb' | |
gem 'git' | |
gem 'edn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'asciidoctor-pdf' | |
require 'rake/clean' | |
require 'git' | |
require 'asciidoctor-diagram/plantuml' | |
VERSION = "0.1" | |
OUT_DIR = "output" | |
# for asciidoctor logging: | |
#$VERBOSE=true | |
directory OUT_DIR | |
def render_file(adoc_path) | |
g = Git.open('.') | |
git_commit_date = g.log[0].date.strftime("%d %B %Y") | |
git_commit_id = g.log[0].sha[1..12] | |
Asciidoctor.render_file adoc_path, | |
:to_dir => OUT_DIR, | |
:safe => 'unsafe', | |
:verbose => 2, | |
:in_place => true, | |
:backend => 'pdf', | |
:attributes => { | |
'project-version' => git_commit_date, | |
'pdf-stylesdir' => 'src/theme', | |
'pdf-fontsdir' => 'src/fonts', | |
'pdf-style' => 'custom', | |
'imagesdir'=> 'images', | |
'imagesoutdir' => 'images', | |
'toc'=> 'left', | |
'toclevels' => 3, | |
'icons'=> 'font', | |
'setanchors'=> 'true', | |
'sectnums' => 'y', | |
'sectnumlevels' => 5, | |
'idprefix' => '', | |
'idseparator' => '-', | |
'git-commit-date' => git_commit_date, | |
'git-commit-id' => git_commit_id | |
} | |
end | |
def render_html_file(adoc_path) | |
g = Git.open('.') | |
git_commit_date = g.log[0].date.strftime("%d %B %Y") | |
git_commit_id = g.log[0].sha[1..12] | |
Asciidoctor.render_file adoc_path, | |
:to_dir => OUT_DIR, | |
:safe => 'unsafe', | |
:in_place => true, | |
:backend => 'html', | |
:attributes => { | |
'project-version' => git_commit_date, | |
'pdf-stylesdir' => 'src/theme', | |
'pdf-fontsdir' => 'src/fonts', | |
'pdf-style' => 'custom', | |
'imagesdir'=> 'images', | |
'imagesoutdir' => 'images', | |
'toc'=> 'left', | |
'toclevels' => 3, | |
'icons'=> 'font', | |
'setanchors'=> 'true', | |
'sectnums' => 'y', | |
'sectnumlevels' => 5, | |
'idprefix' => '', | |
'idseparator' => '-', | |
'git-commit-date' => git_commit_date, | |
'git-commit-id' => git_commit_id | |
} | |
end | |
desc "Generate report" | |
task :pdf do |t, args| | |
directory 'output' | |
render_file 'src/main-report.adoc' | |
end | |
desc "Generate html" | |
task :html do |t, args| | |
directory 'output' | |
render_html 'src/main-report.adoc' | |
end | |
task :clean do | |
rm_rf "#{OUT_DIR}" | |
end | |
task :default => [:html] do | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment