[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re-write of documentation tree build process
From: |
Han-Wen Nienhuys |
Subject: |
Re: Re-write of documentation tree build process |
Date: |
Thu, 21 Dec 2006 01:08:00 +0100 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20061107) |
John Mandereau escreveu:
> Before the next release including this patch, may I also add a link to
> the French tutorial in index.html.in?
Sure.
Here are some final remarks, and Jan will have a look too. If Jan is
ok, please push to stable/2.10.
>I've moved most stuff from GNUmakefile.in:local-WWW-post to
>stepmake/bin/www_post.py.
Good! Can you put them in buildscripts/
(the stepmake bin/ directory isn't used anymore AFAIK.)
> -$(INSTALL) -m 755 -d $(DESTDIR)$(webdir)
> - cp -a $(outdir)/web-root/ $(DESTDIR)$(webdir)/
> + cp -a $(outdir)/offline-root/ $(DESTDIR)$(webdir)/
>
I tend to use rsync for this; on MacOS X, cp -a doesn't work.
> +# For online docs with content negotiation, issue `make web
> FINAL_TARGETS=online'
> +# For both online and offline docs, issue `make web FINAL_TARGETS="offline
> online"'
> +FINAL_TARGETS = offline
WEB_TARGETS
> +def build_pages_dict (filelist):
> + """Build dictionnary of available translations of each page"""
> + pages_dict = {}
> + for f in filelist:
> + m = html_re.match (f)
> + if m:
> + g = m.groups()
hmm, of course the code of add_html_footer is a complete mess, but
you're excused as it is the combined turd of years of negligence of
add-html-footer.py by Jan and me. Still, you're welcome to clean it up
a bit if possible.
> + wiki_page = ('v%s.%s-' % (versiontup[0], versiontup[1]) + f)
> + wiki_page = re.sub ('out-www/', '', wiki_page)
> + wiki_page = re.sub ('/', '-', wiki_page)
> + wiki_page = re.sub (r'\.-', '', wiki_page)
> + wiki_page = re.sub ('.html', '', wiki_page)
> +
> + wiki_string = ''
> +
> + if wiki_base:
> + wiki_string = (r'''<a href="%(wiki_base)s%(wiki_page)s">Read </a>
> comments on this page, or
> + <a href="%(wiki_base)s%(wiki_page)s?action=edit">add</a> one.''' %
> + { 'wiki_base': wiki_base,
> + 'wiki_page': wiki_page})
> +
I think the wiki stuff can go
> + #subst = globals ()
> + #subst.update (locals())
> + for k in page_flavors.keys():
> + page_flavors[k] = page_flavors[k] % vars ()
> +
> + # urg
> + # maybe find first node?
> + fallback_web_title = '-- --'
> + # ugh, python2.[12] re is broken.
> + #m = re.match ('.*?<title>\(.*?\)</title>', s, re.DOTALL)
> + m = re.match ('[.\n]*?<title>([.\n]*?)</title>', s)
similarly, we don't bother with python 2.1 and 2.2 anymore.
Jan, which is the proper one now?
> diff --git a/stepmake/bin/langdefs.py b/stepmake/bin/langdefs.py
> new file mode 100644
> index 0000000..b6e4508
> --- /dev/null
> +++ b/stepmake/bin/langdefs.py
> @@ -0,0 +1,26 @@
> +def lang_file_name (p, langext, ext):
> + if langext != '':
> + return p + '.' + langext + ext
> + return p + ext
> +
> +class language_def:
class names look like LanguageDef
> diff --git a/stepmake/bin/mirrortree.py b/stepmake/bin/mirrortree.py
> new file mode 100644
> index 0000000..4bbac88
> --- /dev/null
> +++ b/stepmake/bin/mirrortree.py
> @@ -0,0 +1,79 @@
> address@hidden@
> +
> +import re
> +import os
> +
> +def new_link_path (link, dir, r):
> + l = link.split ('/')
> + d = dir.split ('/')
> + i = 0
> + while i < len(d) and l[i] == '..':
> + if r.match (d[i]):
> + del l[i]
> + else:
> + i += 1
> + return '/'.join ([x for x in l if not r.match (x)])
> +
> +def hardlink_tree (input_roots = [],
> + process_dirs = '.*',
> + strip_dir_names = '',
> + exclude_dirs = '',
> + process_files = '.*',
> + exclude_files = '',
> + target_pattern = '',
> + targets = ['.']):
> + """Mirror trees for different targets by hardlinking files.
> +
> + Arguments:
> + input_roots=DIRLIST use DIRLIST as input tree roots list
> + process_dir=PATTERN only process files in directories named PATTERN
> + strip_dir_names=PATTERN strip directories names matching PATTERN
> + (write their content to parent)
> + exclude_dir=PATTERN don't recurse into directories named PATTERN
> + process_files=PATTERN filters files which are hardlinked
> + exclude_files=PATTERN exclude files named PATTERN
> + target_pattern=STRING use STRING as target root directory name
> pattern
> + targets=DIRLIST mkdir each directory in DIRLIST and mirrors
> the tree into each
> + """
> + process_files_re = re.compile (process_files)
> + exclude_dirs_re = re.compile (exclude_dirs)
> + exclude_files_re = re.compile (exclude_files)
> + process_dirs_re = re.compile (process_dirs)
> + strip_dir_names_re = re.compile (strip_dir_names)
> + do_strip_dir_names_re = re.compile ('/(?:' + strip_dir_names + ')')
> +
> + if not '%s' in target_pattern:
> + target_pattern += '%s'
> + target_dirs = [target_pattern % s for s in targets]
> +
> + map (os.mkdir, target_dirs)
> +
btw, what happens if target_dirs already exists?
> diff --git a/stepmake/bin/www_post.py b/stepmake/bin/www_post.py
> new file mode 100644
> index 0000000..a2fd52e
> --- /dev/null
> +++ b/stepmake/bin/www_post.py
> @@ -0,0 +1,63 @@
> address@hidden@
> +
> +## This is www_post.py. This script is the main stage
> +## of toplevel GNUmakefile local-WWW-post target.
> +
> +# USAGE: www_post PACKAGE_NAME TOPLEVEL_VERSION STEP-BINDIR OUTDIR TARGETS
> +# please call me from top of the source directory
> +
> +import sys
> +import os
> +import re
> +import subprocess
> +
> +package_name, package_version, step_bindir, outdir, targets = sys.argv[1:]
> +targets = targets.split (' ')
> +outdir = os.path.normpath (outdir)
> +doc_dirs = ['input', 'Documentation', outdir]
> +target_pattern = os.path.join (outdir, '%s-root')
> +
> +static_files = {os.path.join (outdir, 'index.html'):
> + '''<META HTTP-EQUIV="refresh"
> content="0;URL=Documentation/index.html">
> +<html><body>Redirecting to the documentation index...</body></html>\n''',
> + os.path.join (outdir, 'VERSION'):
> + package_version + '\n' }
> +
> +for f in static_files.keys():
> + open (f, 'w').write (static_files[f])
for (f, content) in static_files.items():
open ( .. ) .write (content)
is a little tighter.
> + targets = targets)
> +find_html = subprocess.Popen (['find'] + doc_dirs + ['-name', '*.html'],
> + stdout = subprocess.PIPE,
> + bufsize = -1)
> +find_output = find_html.stdout.read ()
> +n = find_html.wait ()
os.popen (..command..).read ()
Still more python is to use os.walk(), but it's a little more work.
> +if n != 0:
> + sys.exit (n)
> +html_list = find_output.split ('\n')
> +html_list = [f for f in html_list if not (f == '' or 'fr/' in f)]
fr/
should come from the new language module.
--
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen
LilyPond Software Design
-- Code for Music Notation
http://www.lilypond-design.com
- Re-write of documentation tree build process, John Mandereau, 2006/12/14
- Re: Re-write of documentation tree build process, Han-Wen Nienhuys, 2006/12/15
- Re: Re-write of documentation tree build process, John Mandereau, 2006/12/17
- Re: Re-write of documentation tree build process, John Mandereau, 2006/12/20
- Re: Re-write of documentation tree build process,
Han-Wen Nienhuys <=
- Re: Re-write of documentation tree build process, John Mandereau, 2006/12/21
- Re: Re-write of documentation tree build process, Juergen Reuter, 2006/12/21
- Re: Re-write of documentation tree build process, Jan Nieuwenhuizen, 2006/12/21
- Re: Re-write of documentation tree build process, John Mandereau, 2006/12/23
- Re: Re-write of documentation tree build process, Han-Wen Nienhuys, 2006/12/23
- Re: Re-write of documentation tree build process, Jan Nieuwenhuizen, 2006/12/24
- Re: Re-write of documentation tree build process, John Mandereau, 2006/12/27
- Re: Re-write of documentation tree build process, Han-Wen Nienhuys, 2006/12/27