You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2014/12/23 12:14:13 UTC

[1/3] incubator-brooklyn git commit: try reading from disk when computing site structure

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d57521c59 -> ae91215e5


try reading from disk when computing site structure

needed e.g. when building guide with website excluded,
without this the website's menu is not included


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

Branch: refs/heads/master
Commit: e8588ef58457c0f27e9f6df7bd448de3bc9ae042
Parents: adcddb7
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Dec 22 16:42:59 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Dec 22 16:43:57 2014 +0000

----------------------------------------------------------------------
 docs/_plugins/site_structure.rb | 56 ++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e8588ef5/docs/_plugins/site_structure.rb
----------------------------------------------------------------------
diff --git a/docs/_plugins/site_structure.rb b/docs/_plugins/site_structure.rb
index af98473..e943730 100644
--- a/docs/_plugins/site_structure.rb
+++ b/docs/_plugins/site_structure.rb
@@ -5,38 +5,64 @@ module SiteStructure
   BROOKLYN_WEBSITE_ROOT = "/website/index.md" unless defined? BROOKLYN_WEBSITE_ROOT
   
   class Generator < Jekyll::Generator
-    def find_page_with_path_absolute_or_relative_to(site, path, referrent)
-      page = site.pages.detect { |page| "/"+page.path == path }
-      if !page && referrent
-        page = site.pages.detect { |page| "/"+page.path == "/"+File.dirname(referrent.path)+"/"+path }
-      end
+    def find_page_with_path_absolute_or_relative_to(site, path, referrent, structure_processed_pages)
+      uncleaned_path = path
+      
+      # Pathname API ignores first arg below if second is absolute
+      file = Pathname.new(File.dirname(referrent ? referrent.path : "")) + path
+      file = file.cleanpath
+      # is there a better way to trim a leading / ?
+      file = file.relative_path_from(Pathname.new("/")) unless file.relative?
+      path = "#{file}"
+        
+      # look in our cache        
+      page = structure_processed_pages.detect { |item| item['path'] == path }
+      return page if page != nil
+      
+      # look in site cache
+      page = site.pages.detect { |page| page.path == path }
       if !page
-        page = site.pages.detect { |page| page.path == path }
+        page = site.pages.detect { |page| '/'+page.path == uncleaned_path }
         puts "WARNING: link to #{path} in #{referrent ? referrent.path : "root"} uses legacy absolute syntax without leading slash" if page
       end
 
-      throw "Could not find a page called: #{path} (referenced from #{referrent ? referrent.path : "root"})" unless page
+      unless page
+        # could not load it from pages, look on disk
+                 
+        raise "No such file #{path} in site_structure call (from #{referrent ? referrent.path : ""})" unless file.exist?
+#        puts "INFO: reading excluded file #{file} for site structure generation"
+        page = Jekyll::Page.new(site, site.source, File.dirname(file), File.basename(file))
+        
+        throw "Could not find a page called: #{path} (referenced from #{referrent ? referrent.path : "root"})" unless page
+      end
 
+      # now apply standard clean-up
       if (page.url.start_with?("/website"))
         page.url.slice!("/website")
         page.url.prepend(site.config['path']['website'])
       end
+      if (page.url.start_with?("/guide"))
+        page.url.slice!("/guide")
+        page.url.prepend(site.config['path']['guide'])
+      end
+      # and put in cache
+      structure_processed_pages << page
  
       page     
     end
 
     def generate(site)
-      return nil if site.config['exclude'].index(File.dirname(Pathname.new(SiteStructure::BROOKLYN_WEBSITE_ROOT)))
-      root_page = find_page_with_path_absolute_or_relative_to(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil)
+      structure_processed_pages = []
+      root_page = find_page_with_path_absolute_or_relative_to(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil, structure_processed_pages)
       navgroups = root_page.data['navgroups']
       navgroups.each do |ng|
-        ng['page'] = find_page_with_path_absolute_or_relative_to(site, ng['page'], root_page)
+        ng['page'] = find_page_with_path_absolute_or_relative_to(site, ng['page'], root_page, structure_processed_pages)
         if not ng['title_in_menu']
           ng['title_in_menu'] = ng['title'].capitalize
         end
       end
       site.data['navgroups'] = navgroups
-      site.data['structure'] = gen_structure(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil, navgroups)
+      site.data['structure'] = gen_structure(site, SiteStructure::BROOKLYN_WEBSITE_ROOT, nil, navgroups, structure_processed_pages)
     end
 
     def render_liquid(site, page, content)
@@ -44,8 +70,8 @@ module SiteStructure
       page.render_liquid(content, site.site_payload, info)
     end
         
-    def gen_structure(site, pagename, parent, navgroups)
-      page = find_page_with_path_absolute_or_relative_to(site, pagename, parent)
+    def gen_structure(site, pagename, parent, navgroups, structure_processed_pages)
+      page = find_page_with_path_absolute_or_relative_to(site, pagename, parent, structure_processed_pages)
       
       # My navgroup is (first rule matches):
       # 1. what I have explicitly declared
@@ -59,7 +85,7 @@ module SiteStructure
           page.data['navgroup'] = parent.data['navgroup']
         end
       end
-      
+            
       # Figure out second level menu
       # If there's no parent => I'm at the top level, so no action
       # If there's a parent, but parent has no parent => I'm at second level, so set second-level menu
@@ -77,7 +103,7 @@ module SiteStructure
         page.data['children'].each do |c|
           if c['path']
             # links to another Jekyll site-structured page
-            c['reference'] = gen_structure(site, render_liquid(site, page, c['path']), page, navgroups)
+            c['reference'] = gen_structure(site, render_liquid(site, page, c['path']), page, navgroups, structure_processed_pages)
           elsif c['link']
             # links to a non-site-structured page, on this site or elsewhere
             # allow title and link to use vars and tags (liquid processing)


[3/3] incubator-brooklyn git commit: Merge and close #415

Posted by ri...@apache.org.
Merge and close #415


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

Branch: refs/heads/master
Commit: ae91215e56933b025b3e03281428d4a905c520f6
Parents: d57521c 39e02b4
Author: Richard Downer <ri...@apache.org>
Authored: Tue Dec 23 11:13:52 2014 +0000
Committer: Richard Downer <ri...@apache.org>
Committed: Tue Dec 23 11:13:52 2014 +0000

----------------------------------------------------------------------
 docs/README.md                  |  5 ++++
 docs/_build/build.sh            | 36 ++++++++++++++---------
 docs/_plugins/site_structure.rb | 56 ++++++++++++++++++++++++++----------
 3 files changed, 68 insertions(+), 29 deletions(-)
----------------------------------------------------------------------



[2/3] incubator-brooklyn git commit: allow `--skip-javadoc` on builds if javadoc is already built

Posted by ri...@apache.org.
allow `--skip-javadoc` on builds if javadoc is already built


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/39e02b41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/39e02b41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/39e02b41

Branch: refs/heads/master
Commit: 39e02b41fc5fa1e10896e8a3e80bcce724fceabb
Parents: e8588ef
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Dec 22 19:33:26 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Dec 22 19:33:26 2014 +0000

----------------------------------------------------------------------
 docs/README.md       |  5 +++++
 docs/_build/build.sh | 36 ++++++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/39e02b41/docs/README.md
----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index caaea02..4fb6b5d 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -221,6 +221,11 @@ Then check in the changes (probably picking a better message than shown here):
 
 The changes should become live within a few minutes.
 
+SVN commits can be **slow**, particularly if you've regenerated javadoc.
+(The date is included in all javadoc files so the commands above will cause *all* javadoc to be updated.)
+Use `_build/build.sh guide-version --install --skip-javadoc` to update master while re-using the previously installed javadoc.
+That command will fail if javadoc has not been generated for that version.
+
 
 More Notes on the Code
 ----------------------

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/39e02b41/docs/_build/build.sh
----------------------------------------------------------------------
diff --git a/docs/_build/build.sh b/docs/_build/build.sh
index ced17a7..a56f4c3 100755
--- a/docs/_build/build.sh
+++ b/docs/_build/build.sh
@@ -54,7 +54,7 @@ function parse_mode() {
     DIRS_TO_MOVE_TARGET[1]=v/latest/style
     INSTALL_RSYNC_OPTIONS=""
     INSTALL_RSYNC_SUBDIR=${DIRS_TO_MOVE_TARGET[0]}/
-    JAVADOC_TARGET=_site/${DIRS_TO_MOVE_TARGET[0]}/use/api/
+    JAVADOC_TARGET=${DIRS_TO_MOVE_TARGET[0]}/use/api/
     SUMMARY="user guide files in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   guide-version)
@@ -67,14 +67,14 @@ function parse_mode() {
     DIRS_TO_MOVE_TARGET[1]=${DIRS_TO_MOVE_TARGET[0]}/style
     INSTALL_RSYNC_OPTIONS=""
     INSTALL_RSYNC_SUBDIR=${DIRS_TO_MOVE_TARGET[0]}/
-    JAVADOC_TARGET=_site/${DIRS_TO_MOVE_TARGET[0]}/use/api/
+    JAVADOC_TARGET=${DIRS_TO_MOVE_TARGET[0]}/use/api/
     SUMMARY="user guide files in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   test-guide-root)
     JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-root.yml
     DIRS_TO_MOVE[0]=guide
     DIRS_TO_MOVE_TARGET[0]=""
-    JAVADOC_TARGET=_site/use/api/
+    JAVADOC_TARGET=use/api/
     SUMMARY="user guide files in the root"
     ;;
   test-both)
@@ -83,7 +83,7 @@ function parse_mode() {
     DIRS_TO_MOVE_TARGET[0]=v/latest
     DIRS_TO_MOVE[1]=website
     DIRS_TO_MOVE_TARGET[1]=""
-    JAVADOC_TARGET=_site/${DIRS_TO_MOVE_TARGET[0]}/use/api/
+    JAVADOC_TARGET=${DIRS_TO_MOVE_TARGET[0]}/use/api/
     SUMMARY="all files, website in root and guide in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   test-both-sub)
@@ -94,7 +94,7 @@ function parse_mode() {
     DIRS_TO_MOVE_TARGET[1]=brooklyn
     DIRS_TO_MOVE[2]=style
     DIRS_TO_MOVE_TARGET[2]=brooklyn/style
-    JAVADOC_TARGET=_site/${DIRS_TO_MOVE_TARGET[0]}/use/api/
+    JAVADOC_TARGET=${DIRS_TO_MOVE_TARGET[0]}/use/api/
     SUMMARY="all files in /brooklyn"
     ;;
   original)
@@ -168,11 +168,11 @@ function make_javadoc() {
   fi
   popd > /dev/null
   if [ ! -z "$JAVADOC_TARGET" ]; then
-    if [ ! -d "$JAVADOC_TARGET" ]; then
-      echo "ERROR: javadoc target directory $JAVADOC_TARGET gone; is there a jekyll already watching?"
+    if [ ! -d "_site/$JAVADOC_TARGET" ]; then
+      echo "ERROR: javadoc target directory _site/$JAVADOC_TARGET gone; is there a jekyll already watching?"
       return 1
     fi
-    mv _build/target/apidocs/* $JAVADOC_TARGET
+    mv _build/target/apidocs/* _site/$JAVADOC_TARGET
   fi
 }
 
@@ -189,12 +189,6 @@ function make_install() {
     return 1
   fi
   if [ ! -z ${QUICK_JAVADOC+SET} ]; then echo "ERROR: --install not permitted when doing quick javadoc" ; return 1 ; fi
-  if [ ! -z ${JAVADOC_TARGET+SET} ]; then
-    if [ ! -z ${SKIP_JAVADOC+SET} ]; then
-      echo "ERROR: --install not permitted when skipping javadoc for this target which wants to install javadoc"
-      return 1
-    fi
-  fi
 
   SITE_DIR=${BROOKLYN_SITE_DIR-../../incubator-brooklyn-site-public}
   ls $SITE_DIR/style/img/apache-brooklyn-logo-244px-wide.png > /dev/null || { echo "ERROR: cannot find incubator-brooklyn-site-public; set BROOKLYN_SITE_DIR" ; return 1 ; }
@@ -202,6 +196,20 @@ function make_install() {
   if [ -z ${INSTALL_RSYNC_SUBDIR+SET} ]; then echo "ERROR: --install not supported for this build" ; return 1 ; fi
   
   RSYNC_COMMAND_BASE="rsync -rvi --delete --exclude .svn"
+  
+  if [ ! -z ${JAVADOC_TARGET+SET} ]; then
+    if [ ! -z ${SKIP_JAVADOC+SET} ]; then
+      echo 'grep "Generated by javadoc" '$SITE_DIR/$INSTALL_RSYNC_SUBDIR/use/api/index.html
+      export JAVADOC_LAST_DATE=`grep "Generated by javadoc" $SITE_DIR/$INSTALL_RSYNC_SUBDIR/use/api/index.html`
+      if [ -z "$JAVADOC_LAST_DATE" ]; then
+        echo "ERROR: installing with skipped javadoc, but no previous javadoc exists"
+        return 1
+      fi
+      echo "Installing with skipped javadoc, reusing old: $JAVADOC_LAST_DATE"
+      RSYNC_COMMAND_BASE="$RSYNC_COMMAND_BASE --exclude use/api"
+    fi
+  fi
+  
   RSYNC_COMMAND="$RSYNC_COMMAND_BASE $INSTALL_RSYNC_OPTIONS ./_site/$INSTALL_RSYNC_SUBDIR $SITE_DIR/$INSTALL_RSYNC_SUBDIR"
   echo INSTALLING to local site svn repo with: $RSYNC_COMMAND
   $RSYNC_COMMAND || return 1