You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/02/05 06:18:47 UTC

[7/8] mesos git commit: Updated Rakefile to support subdirectories in /docs folder.

Updated Rakefile to support subdirectories in /docs folder.

Previously, the Rakefile for generating the mesos documentation
website didn't support subdirectories containing markdown in the /docs
folder. Specifically, no subdirectores were cpoied from the /docs
folder into the site/documentation/latest folder for the website.
Moreover, the regex used to patch relative links for the markdown
files was incomplete. It didn't support subfolders contaning a
top level index.md file (e.g. mydirectory/index.md). Also, due to a
limitation in Middleman, it didn't support .md files named (e.g.
state.json.md). Middleman would generate an *html* file called
state.json from this instead of generating the standard
state.json/index.html like it does for other .md files.

This commit updates the Rakefile to support these features properly.

Review: https://reviews.apache.org/r/43221/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b4600b9d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b4600b9d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b4600b9d

Branch: refs/heads/master
Commit: b4600b9d0323b2e2a0bffa2e92af738a9e124db2
Parents: cbc7b60
Author: Kevin Klues <kl...@gmail.com>
Authored: Thu Feb 4 20:27:49 2016 -0800
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Thu Feb 4 21:18:18 2016 -0800

----------------------------------------------------------------------
 site/Rakefile | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b4600b9d/site/Rakefile
----------------------------------------------------------------------
diff --git a/site/Rakefile b/site/Rakefile
index 0ce4b79..10817d4 100644
--- a/site/Rakefile
+++ b/site/Rakefile
@@ -25,21 +25,42 @@ task :update_docs do
 
   puts "Updating docs to the latest version"
   FileUtils.mkdir_p("source/documentation/latest/")
-  FileUtils.rm_f(Dir.glob("source/documentation/latest/*.md"))
-  FileUtils.cp_r(Dir.glob("../docs/*.md"), File.expand_path("source/documentation/latest/"))
+  FileUtils.rm_rf(Dir.glob("source/documentation/latest/*"))
+  FileUtils.cp_r(FileList['../docs/**'].exclude("../docs/images"), File.expand_path("source/documentation/latest/"))
+
+  # Due to a limitation in middleman, it doesn't support .md files
+  # named (e.g.  state.json.md). Middlman would generate an *html* file
+  # called state.json from this instead of generating the standard
+  # state.json/index.html like it does for other .md files.
+  puts "Migrating markdown files with paths matching **/*.json.md to **/*.json/index.md"
+  Dir.chdir("#{docs_dir}/latest/") {
+    Dir.glob('**/*.json.md').each { |doc|
+      docdir = doc.chomp(".md")
+      FileUtils.mkdir(docdir)
+      FileUtils.mv(doc, docdir + "/index.md")
+    }
+  }
+
   puts "Parse documentation files to removing md extension in any links"
   Dir.chdir("#{docs_dir}/latest/") {
-    Dir.glob('*.md').each { |doc|
+    Dir.glob('**/*.md').each { |doc|
       puts "working on: #{doc}"
+
+      # TODO(klueska): we really need to get rid of this complicated
+      # regular expression and add in some logic that is more easily
+      # understood.
+      docdir = File.dirname(doc)
       IO.write(doc, File.open(doc) { |f|
         f.read
-          .gsub(/\(([^(\/]+)\.md(\#.+?)?\)/, '(/documentation/latest/\1/\2)')
+          .gsub(/\(([^(]+?)(?:\/index)?\.md(\#.+?)?\)/, "(/documentation/latest/#{docdir}/" + '\1/\2)')
           .gsub(/\(images\/(.*)\)/, '(/assets/img/documentation/\1)')
       })
     }
   }
+
   puts "Moving documentation index to its own 'latest' directory"
   FileUtils.mv("source/documentation/latest/home.md", "source/documentation/latest.html.md")
+
   puts "Documentation updated"
 
   # Copy the images from the docs