diff --git a/scripts/gen_help_html.py b/scripts/gen_help_html.py index 6cca81d250..f3dd19abb6 100644 --- a/scripts/gen_help_html.py +++ b/scripts/gen_help_html.py @@ -23,7 +23,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import re, urllib.parse +import os +import re +import urllib.parse +import datetime +import sys from itertools import chain HEAD = """\ @@ -32,6 +36,17 @@ HEAD = """\ + Nvim: {filename} """ @@ -39,22 +54,19 @@ HEAD_END = '\n\n' INTRO = """

Nvim help files

-

HTML export of the Nvim help pages{vers-note}. -Updated automatically from the Nvim source repository. -Also includes the Vim FAQ, pulled from its -source repository.

+

+Nvim help pages{vers-note}. +Updated automatically +from the Nvim source. +

""" -VERSION_NOTE = ", current as of Vim {version}" +VERSION_NOTE = ", current as of Nvim {version}" SITENAVI_LINKS = """ -Quick links: -help overview · -quick reference · -user manual toc · -reference manual toc · -faq +Quick reference · +User manual · +Reference manual · """ SITENAVI_LINKS_PLAIN = SITENAVI_LINKS.format(helptxt='help.txt.html') @@ -77,15 +89,14 @@ TEXTSTART = """ FOOTER = '' FOOTER2 = """ - + -""" - -VIM_FAQ_LINE = '' \ - 'vim_faq.txt Frequently Asked Questions\n' +""".format( + generated_date='{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()), + commit='?') RE_TAGLINE = re.compile(r'(\S+)\s+(\S+)') @@ -127,6 +138,8 @@ RE_TAGWORD = re.compile( PAT_URL + '|' + PAT_WORD) RE_NEWLINE = re.compile(r'[\r\n]') +# H1 header "=====…" +# H2 header "-----…" RE_HRULE = re.compile(r'[-=]{3,}.*[-=]{3,3}$') RE_EG_START = re.compile(r'(?:.* )?>$') RE_EG_END = re.compile(r'\S') @@ -211,13 +224,20 @@ class VimH2H(object): inexample = 0 filename = str(filename) is_help_txt = (filename == 'help.txt') - faq_line = False + last = '' for line in RE_NEWLINE.split(contents): line = line.rstrip('\r\n') line_tabs = line line = line.expandtabs() + if last == 'h1': + out.extend(('')) # XXX + out.extend(('

', line.rstrip(), '

\n')) + out.extend(('
'))
+                last = ''
+                continue
             if RE_HRULE.match(line):
-                out.extend(('', line, '\n'))
+                # out.extend(('', line, '\n'))
+                last = 'h1'
                 continue
             if inexample == 2:
                 if RE_EG_END.match(line):
@@ -234,8 +254,6 @@ class VimH2H(object):
                 m = RE_SECTION.match(line)
                 out.extend((r'', m.group(0), r''))
                 line = line[m.end():]
-            if is_help_txt and RE_LOCAL_ADD.match(line_tabs):
-                faq_line = True
             lastpos = 0
             for match in RE_TAGWORD.finditer(line):
                 pos = match.start()
@@ -278,9 +296,6 @@ class VimH2H(object):
                 out.append(html_escape[line[lastpos:]])
             out.append('\n')
             if inexample == 1: inexample = 2
-            if faq_line:
-                out.append(VIM_FAQ_LINE)
-                faq_line = False
 
         header = []
         header.append(HEAD.format(encoding=encoding, filename=filename))
@@ -310,9 +325,6 @@ html_escape = HtmlEscCache()
 
 
 
-import sys, os, os.path
-#import cProfile
-sys.path.append('.')
 
 def slurp(filename):
     try:
@@ -352,4 +364,3 @@ def main():
         of.close()
 
 main()
-#cProfile.run('main()')