Skip to content

Commit

Permalink
Reworked changelogs & blog messages - now stored in ./doc/change and …
Browse files Browse the repository at this point in the history
…./doc/blog

First attempt at generating a static website using the more than excellent pelican
  • Loading branch information
Mark Fiers committed Aug 6, 2012
1 parent b0172d7 commit f6fa3b3
Show file tree
Hide file tree
Showing 44 changed files with 798 additions and 12 deletions.
11 changes: 11 additions & 0 deletions lib/python/moa/jobConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ def setPrivateVar(self, k, v):
# i += 1


def getFlags(self, key):
rv = []
if self.is_local(key):
rv.append('L')
else:
rv.append('R')
if self.isPrivate(key):
rv.append('P')

return "".join(rv)

def getRendered(self, key):
""" Get the rendered value of this key"""
return self.interpret(self.get(key, ""))
Expand Down
2 changes: 1 addition & 1 deletion lib/python/moa/plugin/job/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def hook_finish(job):

params = job.conf.getPublicParameters()
with open(os.path.join(compdir, 'parameters'), 'w') as F:
F.write(" ".join(params))
F.write(" ".join(map(str, params)))
return


61 changes: 51 additions & 10 deletions lib/python/moa/plugin/system/doc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"""
import os
import sys

import jinja2
import socket
import getpass
import datetime
import subprocess
Expand All @@ -24,6 +27,8 @@
import moa.logger as l
from moa.sysConf import sysConf

from moa.plugin.system.doc import pelican_util

def hook_finish():

job = sysConf['job']
Expand All @@ -36,12 +41,13 @@ def hook_finish():
return

message = moa.ui._textFormattedMessage(
[ sysConf.args.changeMessage,
[ 'changelog',
sysConf.args.changeMessage,
sysConf.doc.changeMessage ] )

if message:
_appendMessage(
fileName="CHANGELOG.md",
_writeMessage(
category='change',
txt = message)

def hook_defineOptions():
Expand All @@ -67,10 +73,14 @@ def _writeMessage(category, txt):
category, now.year, now.month, now.day,
now.hour, now.minute, now.second))

title = "%s" % category.capitalize()
title = txt[0]
txt = txt[1:]

#title = "%s" % category.capitalize()

with open(filename, "w") as F:
F.write("Title: %s\n\n" % title)
F.write("Title: %s\n" % title)
F.write("Author: %s\n\n" % getpass.getuser())
F.write("\n".join(txt))

#header = "**%s - %s changes**" % (
Expand All @@ -80,7 +90,7 @@ def _writeMessage(category, txt):
#F.write("\n-----\n")
#F.write(oldFile)

def _readFromuser(job, header, category):
def _readFromuser(job, header):
"""
gather blog or changelog information
"""
Expand Down Expand Up @@ -128,7 +138,7 @@ def blog(job, args):


if args.message:
message = " ".join(args.message)
message = [" ".join(args.message)]
else:
message = _readFromuser(
job,
Expand All @@ -137,7 +147,7 @@ def blog(job, args):

if sin:
message.append("\nStdin:\n")
message.extend([" " + x for x in sin.split("\n")])
message.extend([" " + x for x in sin.split("\n")])


_writeMessage('blog', message)
Expand Down Expand Up @@ -213,15 +223,46 @@ def change(job, args):
sysConf.doc.changeMessage = "\n".join(message)


@moa.args.doNotLog
@moa.args.needsJob
@moa.args.addFlag('-f', '--force', help='force rewriting of configuration')
@moa.args.command
def pelican(job, args):
"""
Run pelican :)
"""

themedir = os.path.join(os.path.dirname(__file__), 'theme')
sysConf.doc.server = socket.gethostname()
peliconf = '.moa/pelican.conf.py'
renderdir = 'doc/pelican'

if not os.path.exists('doc'):
moa.ui.message("Nothing to generate")
return ""
os.makedirs('doc')

pelican_util.generate_parameter_page(job)
pelican_util.generate_file_page(job)
pelican_util.generate_readme_page(job)

if args.force or (not os.path.exists(peliconf)):
jenv = jinja2.Environment(loader=jinja2.PackageLoader('moa.plugin.system.doc'))
jtemplate = jenv.select_template(['pelican.conf.jinja2'])

txt = jtemplate.render(sysConf)
with open(peliconf, 'w') as F:
F.write(txt)

if not os.path.exists(renderdir):
os.makedirs(renderdir)

cl = 'pelican -q -t %s -s .moa/pelican.conf.py -o doc/pelican/ doc/' % (
themedir)


P = subprocess.Popen(cl, shell=True)




@moa.args.command
def readme(job, args):
Expand Down
16 changes: 16 additions & 0 deletions lib/python/moa/plugin/system/doc/templates/file.page.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Title: filesets

Set | Name | Typ | Cat | File
-----|--------------|-----|---------|----------------------------------------------
{% for fset in sets %}{%- set outerindex=loop.index -%}
{%- for f in fset -%}
{%- if loop.index0 == 0 -%}
{{ "%03d"|format(outerindex) }}. |
{%- else -%}
{{ "%4s"|format(" ") }} |
{%- endif -%}
{{ "%-12s"|format('**' + f[0][:8] + '**') }} | {{ "%3s"|format(f[1][:3]) }} | {% set dummy=1 -%}
{{ "%6s"|format(f[2][:6]) }} | {% set dummy=2 -%}
[{{ f[4] }}]({{ f[4] }}) **/** [{{ f[5] }}]({{ f[3] }})
{% endfor -%}
{% endfor %}
22 changes: 22 additions & 0 deletions lib/python/moa/plugin/system/doc/templates/parameter.page.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Title: parameters

{% macro printrow(i, name) -%}
{%- set val=conf.get(name, '') -%}
{%- set ren=rendered.get(name, '') -%}
**{{ fsk|format(name) }}** | {{ "%5s"|format(conf.getFlags(name)) }} | {{ fsv|format(ren) }}
{%- if val != ren %}
{{ fsk|format(" ") }} | (raw) | {{ fsv|format(val) }}
{%- endif -%}
{%- endmacro %}
{{head1}}
{{head2}}
{% for p in keys -%}
{% if not conf.isPrivate(p) -%}
{{ printrow(loop.index, p) }}
{% endif -%}
{% endfor -%}
{% for p in keys -%}
{% if conf.isPrivate(p) -%}
{{ printrow(loop.index, p) }}
{% endif -%}
{% endfor %}
21 changes: 21 additions & 0 deletions lib/python/moa/plugin/system/doc/templates/pelican.conf.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

SITEURL = './doc/test/test/pelican/'
SITENAME = "Moa"
DEFAULT_LANG = 'en'
SERVER = u'{{ doc.server }}'
WD= u'{{ job.wd }}'
RELATIVE_URLS = True
DISPLAY_PAGES_ON_MENU = True
DEFAULT_PAGINATION = 5
OUTPUT_PATH = './doc/pelican/'
#PATH = 'doc'
REVERSE_ARCHIVE_ORDER = True
CONTENT_STATIC_LOC = '../../'
MD_EXTENSIONS = ['tables']
SUMMARY_MAX_LENGTH = 550

LINKS = (('Moa docs', 'http://mfiers.github.com/Moa/'),
('Moa source', 'https://github.com/mfiers/Moa'),
)

13 changes: 13 additions & 0 deletions lib/python/moa/plugin/system/doc/theme/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2011 Massimo Santini <santini@dsi.unimi.i>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
5 changes: 5 additions & 0 deletions lib/python/moa/plugin/system/doc/theme/NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This work is derived from the Pelican 'bootstrap' team from Massimo
Santini, which in turn was derived, in part, from Bootstrap, from
Twitter http://twitter.github.com/bootstrap/


0 comments on commit f6fa3b3

Please sign in to comment.