svg2-tools: 3 new changesets

details:   https://svgwg.org/hg/svg2-tools/rev/59efecca3a36
branches:  
changeset: 72:59efecca3a36
user:      Cameron McCormack <cam@mcc.id.au>
date:      Sat Apr 06 12:26:03 2013 +1100
description:
Don't add page header/footer one single page specs.

details:   https://svgwg.org/hg/svg2-tools/rev/5e950c7b185a
branches:  
changeset: 73:5e950c7b185a
user:      Cameron McCormack <cam@mcc.id.au>
date:      Sat Apr 06 12:27:17 2013 +1100
description:
Fix bug in detecting JS errors; only build single page spec if there is more than one page.

details:   https://svgwg.org/hg/svg2-tools/rev/f14102592e40
branches:  
changeset: 74:f14102592e40
user:      Cameron McCormack <cam@mcc.id.au>
date:      Sat Apr 06 13:15:48 2013 +1100
description:
Add support for building other specs.

diffstat:

 build.py              |  51 ++++++++++++++++++++++++++++-----------------------
 publish/config.js     |  12 +++++++++---
 publish/processing.js |  26 +++++++++++++++++---------
 spec.mk               |  16 ++++++++++++++++
 4 files changed, 70 insertions(+), 35 deletions(-)

diffs (258 lines):

diff --git a/build.py b/build.py
--- a/build.py
+++ b/build.py
@@ -32,35 +32,39 @@ def native_path(s):
 # http://stackoverflow.com/questions/1193583/what-is-the-multiplatform-alternative-to-subprocess-getstatusoutput-older-comma
 def getstatusoutput(cmd): 
   """Return (status, output) of executing cmd in a shell."""
   """This new implementation should work on all platforms."""
   import subprocess
   pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
                           universal_newlines=True)  
   output = "".join(pipe.stdout.readlines()) 
-  sts = pipe.returncode
+  sts = pipe.wait()
   if sts is None: sts = 0
   return sts, output
 
 # could allow this to be passed in:
 repo_dir = os.getcwd()
 
 master_dir = join(repo_dir, 'master')
 build_dir = join(repo_dir, 'build')
 publish_dir = join(build_dir, 'publish')
 tools_dir = normpath(join(repo_dir, '..', 'svg2-tools'))
-publishjs_dir = join(tools_dir, 'publish')
 
 if not exists(master_dir):
-  exit(1, 'FAIL: build.py must be run from the root of the \'svg2\' repository')
+  exit(1, 'FAIL: build.py must be run from the root of the \'svg2\' repository '
+          'or from one of the directories under \'specs/\'.')
 
 if not exists(tools_dir):
-  exit(1, 'FAIL: the \'svg2-tools\' repository must be checked out alongside '
-          ' the \'svg2\' repository')
+  tools_dir = normpath(join(repo_dir, '..', '..', '..', 'svg2-tools'))
+  if not exists(tools_dir):
+    exit(1, 'FAIL: the \'svg2-tools\' repository must be checked out alongside '
+            'the \'svg2\' repository')
+
+publishjs_dir = join(tools_dir, 'publish')
 
 if not exists(publish_dir):
   assert os.pardir not in publish_dir
   os.makedirs(publish_dir)
 
 # Add clean-up handler for SIGINT:
 
 def handle_SIGINT(signal, frame):
@@ -160,34 +164,35 @@ if tobuild:
       "\" --build " +
       " ".join(tobuild_names) +
       (" --local-style" if os.environ.get("SVG_BUILD_LOCAL_STYLE_SHEETS") else ""))
   toremove = []
   os.chdir(repo_dir) # chdir back
 
 # Build single page spec as required:
 
-buildSinglePage = False
-single_page = join(publish_dir, "single-page.html")
-
-if not isfile(single_page):
-  buildSinglePage = True
-else:
-  singlePageTime = getmtime(single_page)
-  for name in all:
-    if getmtime(join(publish_dir, name + ".html")) > singlePageTime:
-      buildSinglePage = True
-      break
-
-if buildSinglePage:
-  os.chdir(master_dir)
-  run("node \"" +
-      native_path(join(tools_dir, join("publish","publish.js"))) +
-      "\" --build-single-page")
-  os.chdir(repo_dir) # chdir back
+if len(all) > 1:
+  buildSinglePage = False
+  single_page = join(publish_dir, "single-page.html")
+  
+  if not isfile(single_page):
+    buildSinglePage = True
+  else:
+    singlePageTime = getmtime(single_page)
+    for name in all:
+      if getmtime(join(publish_dir, name + ".html")) > singlePageTime:
+        buildSinglePage = True
+        break
+  
+  if buildSinglePage:
+    os.chdir(master_dir)
+    run("node \"" +
+        native_path(join(tools_dir, join("publish","publish.js"))) +
+        "\" --build-single-page")
+    os.chdir(repo_dir) # chdir back
 
 # Copy over anything else that needs to be copied to 'publish':
 for f in resources:
   tocopypath = join(master_dir, f)
   if os.path.exists(tocopypath):
     copyto = os.path.join(publish_dir,os.path.basename(tocopypath))
     shutil.rmtree(copyto, ignore_errors=True)
     shutil.copytree(tocopypath, copyto)
diff --git a/publish/config.js b/publish/config.js
--- a/publish/config.js
+++ b/publish/config.js
@@ -60,18 +60,24 @@ function gatherSections(conf, page) {
     while (count > 0) {
       sectionHierarchy.pop();
       count--;
     }
   }
 
   function gather(n) {
     if (n.nodeType == 1) {
-      if (/^h[2-6]$/.test(n.nodeName) && n.getAttributeNS(namespaces.edit, 'toc') != 'no') {
-        var id = n.getAttribute("id");
+      var id = n.getAttribute("id");
+      if (/^h[2-6]$/.test(n.nodeName) &&
+          n.getAttributeNS(namespaces.edit, 'toc') != 'no' &&
+          id != 'pagetitle' &&
+          id != 'pagesubtitle' &&
+          id != 'abstract' &&
+          id != 'status' &&
+          id != 'toc') {
         var level = n.nodeName.substring(1) - 1;
         if (section.length >= level - 1) {
           if (section.length == level - 1) {
             section.push(0);
             pushHierarchy();
           } else {
             popHierarchy(section.length - level);
           }
@@ -234,17 +240,17 @@ Config.prototype = {
     }
     if (this.publishDirectory) {
       return '../' + this.publishDirectory + '/';
     }
     return '../publish/';
   },
 
   get isSingleChapter() {
-    return this.pages.length == 1;
+    return this.pageOrder.length == 1;
   },
 
   getPageDocument: function(page) {
     if (!this.pages[page].document) {
       var doc = utils.parseXHTML(page + '.html');
       Object.defineProperty(doc, 'head', { get: function() { return this.getElementsByTagName('head').item(0); } });
       Object.defineProperty(doc, 'body', { get: function() { return this.getElementsByTagName('body').item(0); } });
       this.pages[page].document = doc;
diff --git a/publish/processing.js b/publish/processing.js
--- a/publish/processing.js
+++ b/publish/processing.js
@@ -39,25 +39,28 @@ exports.insertStyleSheets = function(con
   for (var next, n = doc.head.firstChild; n; n = next) {
     next = n.nextSibling;
     if (n.nodeName == 'link' &&
         n.getAttribute('media') != 'print') {
       n.parentNode.removeChild(n);
     }
   }
 
+  var isSVG2 = conf.shortTitle == 'SVG 2';
   // Add a link to the default style sheet.
   doc.head.appendChild(utils.parse('<link rel="stylesheet" title="Default" href="{{href}}" type="text/css" media="screen"/>',
-                                   { href: conf.maturity == 'ED' ? 'style/default_svg.css' : 'style/default_no_maturity.css' }));
+                                   { href: conf.maturity == 'ED' && !isSVG2 ? 'style/default_svg.css' : 'style/default_no_maturity.css' }));
 
-  // Add a link to alternate style sheet to hide background colors
-  // if this is an Editor's Draft, or to show them otherwise.
-  doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="{{title}}" href="{{href}}" type="text/css" media="screen"/>',
-                                   { href: conf.maturity == 'ED' ? 'style/default_no_maturity.css' : 'style/default_svg.css',
-                                     title: conf.maturity == 'ED' ? 'Only annotations for publication' : 'All annotations' }));
+  if (isSVG2) {
+    // Add a link to alternate style sheet to hide background colors
+    // if this is an Editor's Draft, or to show them otherwise.
+    doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="{{title}}" href="{{href}}" type="text/css" media="screen"/>',
+                                     { href: conf.maturity == 'ED' ? 'style/default_no_maturity.css' : 'style/default_svg.css',
+                                       title: conf.maturity == 'ED' ? 'Only annotations for publication' : 'All annotations' }));
+  }
 
   // Add a link to the "no issues/annotations" style sheet.
   doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="No issues/annotations" href="style/default_no_issues.css" type="text/css" media="screen"/>'));
 
   // Add a link to a local or remote W3C TR style sheet for this document's maturity.
   var href = 'W3C-' + conf.shortMaturity;
   if (conf.localStyleSheets) {
     href = 'style/' + href + '.css';
@@ -111,16 +114,20 @@ exports.addBodyClass = function(conf, pa
     doc.body.setAttribute('class', 'chapter-' + page);
   }
 }
 
 
 // -- Add header and footer links to next/previous chapter, etc. --------------
 
 exports.addHeaderFooter = function(conf, page, doc) {
+  if (conf.isSingleChapter) {
+    return;
+  }
+
   var index = conf.pageOrder.indexOf(page);
   var previous = conf.pageOrder[index - 1];
   var next = conf.pageOrder[index + 1];
 
   var markup = '<div class="header {{side}}"><span class="namedate">{{shortTitle}} – {{publicationDate}}</span> <a href="{{index}}.html">Top</a>';
 
   if (conf.toc)            markup += ' â‹… <a href="{{toc}}">Contents</a>';
   if (previous)            markup += ' â‹… <a href="{{previous}}.html">Previous</a>';
@@ -185,22 +192,23 @@ exports.addExpanderScript = function(con
 function generateTOC(conf, page, className) {
   function newTOCUL() {
     return utils.parse('<ul class="{{class}}"></ul>', { class: className });
   }
 
   function generate(ul, children) {
     for (var i = 0; i < children.length; i++) {
       var item = children[i];
-      var li = utils.parse('<li><a href="{{page}}.html#{{id}}"></a></li>',
-                           { page: page,
+      var li = utils.parse('<li><a href="{{url}}#{{id}}"></a></li>',
+                           { url: conf.isSingleChapter ? '' : page + '.html',
                              id: item.section.id });
       var a = li.firstChild;
       if (conf.pages[page].type == 'chapter' || 
-          conf.pages[page].type == 'appendix') {
+          conf.pages[page].type == 'appendix' ||
+          conf.isSingleChapter) {
         a.appendChild(utils.parse('<span class="secno">{{number}}{{section}}.</span> ',
                                   { number: conf.isSingleChapter ? '' : conf.pages[page].formattedNumber + '.',
                                     section: item.section.number }));
       }
       a.appendChild(item.section.title.cloneNode(true));
       if (item.children) {
         var childUL = newTOCUL();
         generate(childUL, item.children);
diff --git a/spec.mk b/spec.mk
new file mode 100644
--- /dev/null
+++ b/spec.mk
@@ -0,0 +1,16 @@
+# Makefile for specs under http://svgwg.org/hg/svg2/specs/.
+
+TOOLS=../../../svg2-tools
+
+all-with-tools-check : tools-check all
+
+tools-check :
+	@bash -c "REMOTE_REV=$$(hg id -i http://svgwg.org/hg/svg2-tools); [ \$$? = 0 -o \"\$$REMOTE_REV\" != \"\" ] || exit 0; LOCAL_REV=$$(hg id -i $(TOOLS)); [ \"\$$LOCAL_REV\" = \"\$$REMOTE_REV\" -o \"\$$LOCAL_REV\" = \"\$$REMOTE_REV\"+ ] || (echo \"You must update your svg2-tools repository! (Remote repository has revision \$$REMOTE_REV, but you are at \$$LOCAL_REV.)\"; exit 1)"
+
+all :
+	@$(TOOLS)/build.py
+
+clean :
+	@$(TOOLS)/build.py -c
+
+.PHONY : all-with-tools-check tools-check all clean

Received on Saturday, 6 April 2013 02:16:26 UTC