diff options
author | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2013-09-20 15:53:53 +0100 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2013-09-20 15:53:53 +0100 |
commit | 2b34dd38f17470d32d98bd641935d55d5ae6792a (patch) | |
tree | e80a382d8a2372d26fd160c9cdec8591b3519685 | |
parent | d093e98cb0c84a9d9c62ed8a0a6f3735f9d8be4b (diff) |
fixed script; added link to test case in gitweb
-rw-r--r-- | docs.py | 23 | ||||
-rwxr-xr-x | docs.sh | 14 | ||||
-rw-r--r-- | templates/testcase.moin | 1 |
3 files changed, 28 insertions, 10 deletions
@@ -5,6 +5,7 @@ from elixir import * from optparse import OptionParser from jinja2 import Environment as JinjaEnv, FileSystemLoader from editmoin import edit as moin_edit, get_user +from urlparse import urlparse #metadata.bind = "sqlite:///docs.db" metadata.bind = "sqlite://" @@ -128,16 +129,17 @@ if __name__ == "__main__": setup_all() create_all() + print options.sha1 repository = Repository(url=options.url, sha1=options.sha1) session.commit() - for root, dirs, files in os.walk('.'): + for root, dirs, files in os.walk('source'): for f in files: if f.endswith('yaml'): stream = open("%s/%s" % (root, f), "r") tc = yaml.load(stream) stream.close() - t = TestCase(script_name=f, script_path=root[2:], repository=repository) + t = TestCase(script_name=f, script_path=root[7:], repository=repository) session.commit() for key, value in tc['metadata'].iteritems(): #print key, value @@ -159,13 +161,26 @@ if __name__ == "__main__": env = JinjaEnv(loader=FileSystemLoader('templates')) tc_template = env.get_template("testcase.%s" % options.format) + parsed_url = urlparse(options.url) + giturl = "%s://%s/" % (parsed_url.scheme, parsed_url.netloc) + gitpath = parsed_url.path + if gitpath.startswith("/git-ro/"): + gitpath = gitpath.replace("/git-ro/", "") for tc in TestCase.query.all(): f = open("%s/%s_%s.%s" % (options.output, tc.script_path.replace("/", "_"), tc.name, options.format), "w") - f.write(tc_template.render(testcase=tc, prefix=options.prefix)) + f.write( + tc_template.render( + testcase=tc, + prefix=options.prefix, + giturl=giturl, + gitpath=gitpath)) f.close() index_template = env.get_template("index.%s" % options.format) f = open("%s/index.%s" % (options.output, options.format), "w") - f.write(index_template.render(testcases=TestCase.query.all(), prefix=options.prefix)) + f.write( + index_template.render( + testcases=TestCase.query.all(), + prefix=options.prefix)) f.close() subindex_template = env.get_template("subindex.%s" % options.format) @@ -18,10 +18,10 @@ EOF } URL= -FORMAT= -OUTPUT= -PREFIX= -WIKI= +FORMAT=moin +OUTPUT=build +PREFIX="" +WIKI="" while getopts “hu:f:o:p:w:” OPTION do case $OPTION in @@ -51,12 +51,14 @@ do esac done -if [[ -z $URL ]] || [[ -z $FORMAT ]] || [[ -z $OUTPUT ]] || [[ -z $PREFIX ]] || [[ -z $WIKI ]] +if [[ -z $URL ]] then usage exit 1 fi -git clone $URL +git clone $URL source +cd source SHA1=`git rev-parse master` +cd .. python docs.py --url $URL --sha1 $SHA1 --format $FORMAT --output $OUTPUT --prefix $PREFIX --wiki $WIKI diff --git a/templates/testcase.moin b/templates/testcase.moin index 7c8069f..0f70598 100644 --- a/templates/testcase.moin +++ b/templates/testcase.moin @@ -1,5 +1,6 @@ [[{{ prefix }}/index | Test Case Index]] +[[{{ giturl }}gitweb?p={{ gitpath }};a=blob;f={{ testcase.script_path }}/{{ testcase.script_name }};hb={{ testcase.repository.sha1 }}|Test Case source]] == {{ testcase.name }} == * format: {{ testcase.format }} * maintainers: |