From b367c63186bad5fd96400ddeedc34bc7a2537710 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sat, 7 Mar 2020 12:31:35 +0100 Subject: Add task for converting Readme to Markdown before publishing on npm --- .gitignore | 1 + .travis.yml | 6 ++++++ Rakefile | 13 +++++++++++++ asciidoctor-interdoc-reftext.gemspec | 3 ++- package.json | 4 ++-- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 586971a..84d654c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ node_modules/ Gemfile.lock package-lock.json +README.md yarn.lock *.bundle *.gem diff --git a/.travis.yml b/.travis.yml index e3a87f2..41d612f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,11 @@ jobs: - env: ASCIIDOCTOR_VERSION="git:master" rvm: *ruby-latest +addons: + apt: + packages: + - pandoc + env: global: secure: "tXxL81YrHRaD90vTdIZ6eKWGQFWAYz9WKf64/xVNZxBiSTaiyabS6/k1XvVTkJ61x389Xcl9sMMFgtP5BCxVpfdOboD1R0v9dSqssPzxIOikw1XiKTJCSWPOoYy/Z8n/jR1U4AzVzhxCDyJrv4bd5NbxegrsV9aeIB5mGrPy1Hxz+IAAZOLTCEwiwFhHMpamn7+NDWMa7WFfBdCfkxO0VOa0hXmI0ogdB+kdRM2q+24bv8zs0OwUTNyd0Y0CtG02/Ad+f8C27mS2kqRpv64NRpiFh1a0RB8Fyj4Beax7VrhxJXYNIq53bBd+ue+DHgAciDpb3fV10sdjYuCmrWlYt9yZiAPBoqfvxL7ymV/AiSLdEBnMxXtK/BnYRmjLYb3kgt4yW9Eqnzy0xsARTSLqznfaV5Mm7nCJuwu5nIePeaL6CbBewu5R64kHn360nhJsLDlzLJnrXgLk0j9+V3LEmmxBn1lYChRZjq71I5D8bOPC7QLOd2Cgx+ObDiDEWSLal5F5DXc3wnbDsDJMsmDQjPt+erAIOv7b91iWQ6znn/75x0P0Rj2WunXwluW1rBqsBeDCsCRUO9qCeJJzr5XworZgSM5vH8Ge9z8C9YG73sCniWhhVZVkN33RWVLRw0MtXqiVP6OgPjLZqPJl4wtKux6EOCLSghb6wbD4ulaGRaw=" # CODACY_PROJECT_TOKEN @@ -56,6 +61,7 @@ script: - bundle exec rake spec - bundle exec rake rubocop - bundle exec rake build:js + - bundle exec rake readme2md deploy: - provider: rubygems diff --git a/Rakefile b/Rakefile index 46dd4bd..46842bf 100644 --- a/Rakefile +++ b/Rakefile @@ -23,6 +23,19 @@ rescue LoadError => e warn "#{e.path} is not available" end +task :readme2md do + require 'asciidoctor' + require 'pandoc-ruby' + + docbook = Asciidoctor + .load_file('README.adoc', header_footer: true, backend: 'docbook') + .convert + markdown = PandocRuby + .convert(docbook, from: :docbook, to: :markdown_github) + + File.write('README.md', markdown) +end + namespace :build do desc 'Transcompile to JavaScript using Opal' task :js do diff --git a/asciidoctor-interdoc-reftext.gemspec b/asciidoctor-interdoc-reftext.gemspec index 01e1eaf..2fdcf09 100644 --- a/asciidoctor-interdoc-reftext.gemspec +++ b/asciidoctor-interdoc-reftext.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.summary = "Asciidoctor extension providing implicit (automatic) reference \ text (label) for inter-document cross references" - s.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README*'] + s.files = Dir['lib/**/*', '*.gemspec', 'LICENSE*', 'README.adoc'] s.has_rdoc = 'yard' s.required_ruby_version = '>= 2.1' @@ -20,6 +20,7 @@ text (label) for inter-document cross references" s.add_development_dependency 'corefines', '~> 1.11' s.add_development_dependency 'kramdown', '~> 1.16' + s.add_development_dependency 'pandoc-ruby', '~> 2.0' s.add_development_dependency 'rake', '~> 12.0' s.add_development_dependency 'rspec', '~> 3.7' s.add_development_dependency 'rspec-html-matchers', '~> 0.9.1' diff --git a/package.json b/package.json index 4b5d5ca..58a08f7 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,10 @@ "files": [ "dist/asciidoctor-interdoc-reftext.js", "LICENSE", - "README.adoc" + "README.md" ], "scripts": { - "prepublishOnly": "bundle install && bundle exec rake build:js" + "prepublishOnly": "bundle install && bundle exec rake build:js && bundle exec rake readme2md" }, "devDependencies": { "@asciidoctor/core": ">=2.0.0 <2.2.0" -- cgit v1.2.3