mailr27579 - /website/api/rehead.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on February 06, 2015 - 10:41:
Author: bugman
Date: Fri Feb  6 10:41:39 2015
New Revision: 27579

URL: http://svn.gna.org/viewcvs/relax?rev=27579&view=rev
Log:
The rehead.py script now modifies the special index.html and frames.html 
Epydoc API documentation files.


Modified:
    website/api/rehead.py

Modified: website/api/rehead.py
URL: 
http://svn.gna.org/viewcvs/relax/website/api/rehead.py?rev=27579&r1=27578&r2=27579&view=diff
==============================================================================
--- website/api/rehead.py       (original)
+++ website/api/rehead.py       Fri Feb  6 10:41:39 2015
@@ -13,17 +13,17 @@
 
 # Blacklisted files to not change.
 BLACKLIST = [
-    'frames.html',
-    'index.html',
     'redirect.html'
 ]
 
 # The contents for the HEAD tag, excluding the title tag.
-HEAD_CONTENTS = [
+HEAD_CONTENTS_CSS = [
     "",
     "  <!--Epydoc setup-->",
     "  <link rel=\"stylesheet\" href=\"epydoc.css\" type=\"text/css\" />",
     "  <script type=\"text/javascript\" src=\"epydoc.js\"></script>",
+]
+HEAD_CONTENTS_SHORT = [
     "",
     "  <!--Mobile device support-->",
     "  <meta name=viewport content=\"width=device-width, initial-scale=1\">",
@@ -44,6 +44,7 @@
     "",
     "  </script>",
 ]
+HEAD_CONTENTS = HEAD_CONTENTS_CSS + HEAD_CONTENTS_SHORT
 
 # The expected head tag contents.
 EXPECTED = [
@@ -101,8 +102,13 @@
                 file.write(title)
                 file.write("\n")
 
+                # The 
+                contents = HEAD_CONTENTS
+                if self.short_head:
+                    contents = HEAD_CONTENTS_SHORT
+
                 # Add the rest of the head contents.
-                for line in HEAD_CONTENTS:
+                for line in contents:
                     file.write("%s\n" % line)
 
                 # Go to the end of the head tag.
@@ -129,6 +135,7 @@
         index = 0
         pre_modified = False
         analytics = False
+        self.short_head = False
         for line in self.file_lines:
             # In the head tag.
             if search("<head>", line):
@@ -144,8 +151,12 @@
                 if index == 4 and line[:-1] == "  <!--Google analytics 
JS-->":
                     analytics = True
 
+                # Short headers.
+                if index == 2 and line[:-1] == "</head>":
+                    self.short_head = True
+
                 # Check the line, skipping the title tag.
-                if not pre_modified and not analytics and EXPECTED[index] != 
None and EXPECTED[index] != line[:-1]:
+                if not pre_modified and not analytics and not 
self.short_head and EXPECTED[index] != None and EXPECTED[index] != line[:-1]:
                     print("%s: Unexpected head tag encountered, quitting." % 
file_name)
                     print("    Encountered line:  \"%s\"" % line[:-1])
                     print("    Expected line:  \"%s\"" % EXPECTED[index])




Related Messages


Powered by MHonArc, Updated Fri Feb 06 11:00:03 2015