[PATCH 2/2] nmbug-status: make output title and blurb configurable

2014-03-13 Thread Jani Nikula
Make nmbug-status more generally usable outside of nmbug by not
hardcoding notmuch related things.

This lets anyone publish html search views to mailing list messages
with a custom config file, independent of nmbug.
---
 devel/nmbug/nmbug-status   |   32 +++-
 devel/nmbug/status-config.json |5 +
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index cb3901f..03621bd 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -242,6 +242,19 @@ class HtmlPage (Page):
 def _slug(self, string):
 return self._slug_regexp.sub('-', string)

+parser = argparse.ArgumentParser()
+parser.add_argument('--text', help='output plain text format',
+action='store_true')
+parser.add_argument('--config', help='load config from given file',
+metavar='PATH')
+parser.add_argument('--list-views', help='list views',
+action='store_true')
+parser.add_argument('--get-query', help='get query for view',
+metavar='VIEW')
+
+args = parser.parse_args()
+
+config = read_config(path=args.config)

 _PAGES['text'] = Page()
 _PAGES['html'] = HtmlPage(
@@ -292,29 +305,14 @@ Generated: {date}
 
 Views
 '''.format(date=datetime.datetime.utcnow().date(),
-   title='Notmuch Patches',
-   blurb='For more infomation see http://notmuchmail.org/nmbug;>nmbug',
+   title=config['meta']['title'],
+   blurb=config['meta']['blurb'],
encoding=_ENCODING,
inter_message_padding='0.25em',
border_radius='0.5em'),
 footer='\n\n',
 )

-
-parser = argparse.ArgumentParser()
-parser.add_argument('--text', help='output plain text format',
-action='store_true')
-parser.add_argument('--config', help='load config from given file',
-metavar='PATH')
-parser.add_argument('--list-views', help='list views',
-action='store_true')
-parser.add_argument('--get-query', help='get query for view',
-metavar='VIEW')
-
-args = parser.parse_args()
-
-config = read_config(path=args.config)
-
 if args.list_views:
 for view in config['views']:
 print(view['title'])
diff --git a/devel/nmbug/status-config.json b/devel/nmbug/status-config.json
index 6b4934f..3f02c81 100644
--- a/devel/nmbug/status-config.json
+++ b/devel/nmbug/status-config.json
@@ -1,4 +1,9 @@
 {
+"meta": {
+"title": "Notmuch Patches",
+"blurb": "For more infomation see http://notmuchmail.org/nmbug;>nmbug"
+},
+
 "views": [
{
"comment": "Unresolved bugs (or just need tag updating).",
-- 
1.7.2.5



[PATCH 1/2] nmbug-status: parametrize title and blurb in the page header

2014-03-13 Thread Jani Nikula
Prepare for more general use.
---
 devel/nmbug/nmbug-status |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 6b2572c..cb3901f 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -249,7 +249,7 @@ _PAGES['html'] = HtmlPage(
 
 
   
-  Notmuch Patches
+  {title}
   
 table {{
   border-spacing: 0;
@@ -285,13 +285,15 @@ _PAGES['html'] = HtmlPage(
   
 
 
-Notmuch Patches
+{title}
 
 Generated: {date}
-For more infomation see http://notmuchmail.org/nmbug;>nmbug
+{blurb}
 
 Views
 '''.format(date=datetime.datetime.utcnow().date(),
+   title='Notmuch Patches',
+   blurb='For more infomation see http://notmuchmail.org/nmbug;>nmbug',
encoding=_ENCODING,
inter_message_padding='0.25em',
border_radius='0.5em'),
-- 
1.7.2.5



[Patch v3 4/4] doc: cosmetic fix for prerst2man.py

2014-03-13 Thread David Bremner
Fix a particular egregious combination of format and string
concatenation.
---
 doc/prerst2man.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/prerst2man.py b/doc/prerst2man.py
index 720deb6..4591264 100644
--- a/doc/prerst2man.py
+++ b/doc/prerst2man.py
@@ -59,4 +59,5 @@ for page in man_pages:
 outfile.write("".join(lines))
 outfile.close()

-os.system('set -x; rst2man {0} {1}'.format(filename, outdir + '/' + 
page[0] + '.' + str(page[4])))
+os.system('set -x; rst2man {0} {1}/{2}.{3}'
+  .format(filename, outdir, page[0],page[4]))
-- 
1.8.5.3



[Patch v3 2/4] doc: build man pages into hierarchy, fix help test.

2014-03-13 Thread David Bremner
It turns out there was a reason the old man pages were stored in a man
compatible hierarchy, namely so that we could run man on them before
installing.

Hardcode doc build location into test suite.  This isn't ideal, but
let's unbreak the test suite for now.
---
 doc/Makefile.local  | 11 +++
 doc/mkdocdeps.py|  2 +-
 test/test-lib-common.sh |  4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/doc/Makefile.local b/doc/Makefile.local
index 23f4095..fab6d48 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -40,7 +40,10 @@ ${MAN_ROFF_FILES}: ${dir}/man.stamp
 $(dir)/man.stamp: ${MAN_RST_FILES}
 ifeq ($(HAVE_SPHINX),1)
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-   touch $@
+   for section in 1 5 7; do \
+   mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
+   mv $(DOCBUILDDIR)/man/*.$${section} 
$(DOCBUILDDIR)/man/man$${section}; \
+   done
 else ifeq ($(HAVE_RST2MAN),1)
$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
touch $@
@@ -52,9 +55,9 @@ install-man: ${MAN_GZIP_FILES}
mkdir -p "$(DESTDIR)$(mandir)/man1"
mkdir -p "$(DESTDIR)$(mandir)/man5"
mkdir -p "$(DESTDIR)$(mandir)/man7"
-   install -m0644 $(DOCBUILDDIR)/man/*.1.gz $(DESTDIR)/$(mandir)/man1
-   install -m0644 $(DOCBUILDDIR)/man/*.5.gz $(DESTDIR)/$(mandir)/man5
-   install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
+   install -m0644 $(DOCBUILDDIR)/man/man1/*.1.gz $(DESTDIR)/$(mandir)/man1
+   install -m0644 $(DOCBUILDDIR)/man/man5/*.5.gz $(DESTDIR)/$(mandir)/man5
+   install -m0644 $(DOCBUILDDIR)/man/man7/*.7.gz $(DESTDIR)/$(mandir)/man7
cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz

 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
diff --git a/doc/mkdocdeps.py b/doc/mkdocdeps.py
index e61bea6..3effdd8 100644
--- a/doc/mkdocdeps.py
+++ b/doc/mkdocdeps.py
@@ -10,7 +10,7 @@ rst_files = []
 out=open(outfile,'w')
 for page in man_pages:
 rst_files = rst_files + ["doc/{0:s}.rst".format(page[0])]
-roff_files = roff_files + 
["{0:s}/man/{1:s}.{2:d}".format(builddir,page[1],page[4])]
+roff_files = roff_files + 
["{0:s}/man/{1:s}.{2:d}".format(builddir,page[0],page[4])]

 out.write ('MAN_ROFF_FILES := ' + ' \\\n\t'.join(roff_files)+'\n')
 out.write ('MAN_RST_FILES := ' + ' \\\n\t'.join(rst_files)+'\n')
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index e1eaa5a..892991e 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -98,12 +98,12 @@ then
PATH=$GIT_VALGRIND/bin:$PATH
GIT_EXEC_PATH=$GIT_VALGRIND/bin
export GIT_VALGRIND
-   test -n "$notmuch_path" && MANPATH="$notmuch_path/man:$MANPATH"
+   test -n "$notmuch_path" && MANPATH="$notmuch_path/doc/_build/man"
 else # normal case
if test -n "$notmuch_path"
then
PATH="$notmuch_path:$PATH"
-   MANPATH="$notmuch_path/man:$MANPATH"
+   MANPATH="$notmuch_path/doc/_build/man"
fi
 fi
 export PATH MANPATH
-- 
1.8.5.3



[Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN

2014-03-13 Thread David Bremner
This helps avoid build artifacts (namely, nroff and gzipped-nroff man
pages) owned by root.

The variables allow choosing which generator to use for the man page.
These will be hooked to configure in a following commit.
---
 Makefile.local |  2 +-
 doc/Makefile.local | 31 ++-
 doc/mkdocdeps.py   |  3 +++
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 5f797ad..cb7b106 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -53,7 +53,7 @@ endif
 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)

 .PHONY: all
-all: notmuch notmuch-shared
+all: notmuch notmuch-shared build-man
 ifeq ($(MAKECMDGOALS),)
 ifeq ($(shell cat .first-build-message 2>/dev/null),)
@NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
diff --git a/doc/Makefile.local b/doc/Makefile.local
index fd64f70..23f4095 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -13,10 +13,9 @@ mkdocdeps := python $(dir)/mkdocdeps.py
 # Internal variables.
 ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)

-.PHONY: sphinx-html sphinx-man sphinx-texinfo sphinx-info
-.PHONY: rst2man
+.PHONY: sphinx-html sphinx-texinfo sphinx-info

-.PHONY: install-man
+.PHONY: install-man build-man

 %.gz: %
rm -f $@ && gzip --stdout $^ > $@
@@ -24,24 +23,30 @@ ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) 
$(dir)
 sphinx-html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html

-sphinx-man:
-   $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-
 sphinx-texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo

 sphinx-info: sphinx-texinfo
make -C $(DOCBUILDDIR)/texinfo info

-# fallback target in case sphinx not installed
-rst2man:
-   $(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
-
 -include $(dir)/docdeps.mk

 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})

-${MAN_ROFF_FILES} : sphinx-man
+build-man: ${MAN_GZIP_FILES}
+
+${MAN_ROFF_FILES}: ${dir}/man.stamp
+
+$(dir)/man.stamp: ${MAN_RST_FILES}
+ifeq ($(HAVE_SPHINX),1)
+   $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
+   touch $@
+else ifeq ($(HAVE_RST2MAN),1)
+   $(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
+   touch $@
+else
+   @echo "No sphinx or rst2man, will not install man pages."
+endif

 install-man: ${MAN_GZIP_FILES}
mkdir -p "$(DESTDIR)$(mandir)/man1"
@@ -52,8 +57,8 @@ install-man: ${MAN_GZIP_FILES}
install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz

-
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
$(mkdocdeps) $< $(DOCBUILDDIR) $@

-CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk
+CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk $(dir)/man.stamp
+CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES)
diff --git a/doc/mkdocdeps.py b/doc/mkdocdeps.py
index 2f4a959..e61bea6 100644
--- a/doc/mkdocdeps.py
+++ b/doc/mkdocdeps.py
@@ -6,8 +6,11 @@ outfile = argv[3]
 execfile(conffile)

 roff_files = []
+rst_files = []
 out=open(outfile,'w')
 for page in man_pages:
+rst_files = rst_files + ["doc/{0:s}.rst".format(page[0])]
 roff_files = roff_files + 
["{0:s}/man/{1:s}.{2:d}".format(builddir,page[1],page[4])]

 out.write ('MAN_ROFF_FILES := ' + ' \\\n\t'.join(roff_files)+'\n')
+out.write ('MAN_RST_FILES := ' + ' \\\n\t'.join(rst_files)+'\n')
-- 
1.8.5.3



No subject

2014-03-13 Thread David Bremner
Several people observed a problem with the test T010-help not finding
the man pages anymore. To fix that, I had change the previous fix:
instead of flattening the rst2man output into one directory, I had to
move the sphinx output into a hierarchy.

Patches 1 and 3 should be the same as 

id:1394539555-28334-1-git-send-email-david at tethera.net



[PATCH 2/2] nmbug-status: make output title and blurb configurable

2014-03-13 Thread Jani Nikula
Make nmbug-status more generally usable outside of nmbug by not
hardcoding notmuch related things.

This lets anyone publish html search views to mailing list messages
with a custom config file, independent of nmbug.
---
 devel/nmbug/nmbug-status   |   32 +++-
 devel/nmbug/status-config.json |5 +
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index cb3901f..03621bd 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -242,6 +242,19 @@ class HtmlPage (Page):
 def _slug(self, string):
 return self._slug_regexp.sub('-', string)
 
+parser = argparse.ArgumentParser()
+parser.add_argument('--text', help='output plain text format',
+action='store_true')
+parser.add_argument('--config', help='load config from given file',
+metavar='PATH')
+parser.add_argument('--list-views', help='list views',
+action='store_true')
+parser.add_argument('--get-query', help='get query for view',
+metavar='VIEW')
+
+args = parser.parse_args()
+
+config = read_config(path=args.config)
 
 _PAGES['text'] = Page()
 _PAGES['html'] = HtmlPage(
@@ -292,29 +305,14 @@ Generated: {date}br /
 /p
 h3Views/h3
 '''.format(date=datetime.datetime.utcnow().date(),
-   title='Notmuch Patches',
-   blurb='For more infomation see a 
href=http://notmuchmail.org/nmbug;nmbug/a',
+   title=config['meta']['title'],
+   blurb=config['meta']['blurb'],
encoding=_ENCODING,
inter_message_padding='0.25em',
border_radius='0.5em'),
 footer='/body\n/html\n',
 )
 
-
-parser = argparse.ArgumentParser()
-parser.add_argument('--text', help='output plain text format',
-action='store_true')
-parser.add_argument('--config', help='load config from given file',
-metavar='PATH')
-parser.add_argument('--list-views', help='list views',
-action='store_true')
-parser.add_argument('--get-query', help='get query for view',
-metavar='VIEW')
-
-args = parser.parse_args()
-
-config = read_config(path=args.config)
-
 if args.list_views:
 for view in config['views']:
 print(view['title'])
diff --git a/devel/nmbug/status-config.json b/devel/nmbug/status-config.json
index 6b4934f..3f02c81 100644
--- a/devel/nmbug/status-config.json
+++ b/devel/nmbug/status-config.json
@@ -1,4 +1,9 @@
 {
+meta: {
+title: Notmuch Patches,
+blurb: For more infomation see a 
href=http://notmuchmail.org/nmbug;nmbug/a
+},
+
 views: [
{
comment: Unresolved bugs (or just need tag updating).,
-- 
1.7.2.5

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/2] nmbug-status: make title/blurb configurable

2014-03-13 Thread Jani Nikula
This lets me use nmbug-status for publishing search views in html
outside of the nmbug context. I'm sure especially 2/2 can be done
better. If someone wants to use their mad python skillz to improve this,
it would be great. ;)

BR,
Jani.


Jani Nikula (2):
  nmbug-status: parametrize title and blurb in the page header
  nmbug-status: make output title and blurb configurable

 devel/nmbug/nmbug-status   |   36 ++--
 devel/nmbug/status-config.json |5 +
 2 files changed, 23 insertions(+), 18 deletions(-)

-- 
1.7.2.5

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] nmbug-status: parametrize title and blurb in the page header

2014-03-13 Thread Jani Nikula
Prepare for more general use.
---
 devel/nmbug/nmbug-status |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/devel/nmbug/nmbug-status b/devel/nmbug/nmbug-status
index 6b2572c..cb3901f 100755
--- a/devel/nmbug/nmbug-status
+++ b/devel/nmbug/nmbug-status
@@ -249,7 +249,7 @@ _PAGES['html'] = HtmlPage(
 html lang=en
 head
   meta http-equiv=Content-Type content=text/html; charset={encoding} /
-  titleNotmuch Patches/title
+  title{title}/title
   style media=screen type=text/css
 table {{
   border-spacing: 0;
@@ -285,13 +285,15 @@ _PAGES['html'] = HtmlPage(
   /style
 /head
 body
-h2Notmuch Patches/h2
+h2{title}/h2
 p
 Generated: {date}br /
-For more infomation see a href=http://notmuchmail.org/nmbug;nmbug/a
+{blurb}
 /p
 h3Views/h3
 '''.format(date=datetime.datetime.utcnow().date(),
+   title='Notmuch Patches',
+   blurb='For more infomation see a 
href=http://notmuchmail.org/nmbug;nmbug/a',
encoding=_ENCODING,
inter_message_padding='0.25em',
border_radius='0.5em'),
-- 
1.7.2.5

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 0/2] nmbug-status: make title/blurb configurable

2014-03-13 Thread W. Trevor King
On Thu, Mar 13, 2014 at 01:04:03PM +0100, Jani Nikula wrote:
 This lets me use nmbug-status for publishing search views in html
 outside of the nmbug context. I'm sure especially 2/2 can be done
 better. If someone wants to use their mad python skillz to improve
 this, it would be great. ;)

Both patches look good to me.  What don't you like about 2/2?

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch