Commit 4913696b authored by Nils Goroll's avatar Nils Goroll

facilitate url_vcc / url_doc formatting for non-github users

This adds a "branch" attribute to the rev objects.

If an "fmt" object exists with attributes "url_vcc" and/or "url_doc",
those are taken as printf formats (which should contain a single %s) and
used with the branch attributes from the revs.
parent 5573e156
...@@ -51,7 +51,15 @@ class vmod(object): ...@@ -51,7 +51,15 @@ class vmod(object):
def url_vcc(self, rev): def url_vcc(self, rev):
r = self.j.get("rev") r = self.j.get("rev")
if r != None: if r != None:
if "url_vcc" in r[rev]:
return r[rev]["url_vcc"] return r[rev]["url_vcc"]
fmt = self.j.get("fmt")
if fmt != None and "url_vcc" in fmt:
fmt = fmt["url_vcc"]
else:
fmt = None
if fmt != None and "branch" in r[rev]:
return fmt % r[rev]["branch"]
g = self.j.get("github") g = self.j.get("github")
if g != None: if g != None:
s = "https://raw.githubusercontent.com/" s = "https://raw.githubusercontent.com/"
...@@ -64,8 +72,16 @@ class vmod(object): ...@@ -64,8 +72,16 @@ class vmod(object):
def url_doc(self, rev): def url_doc(self, rev):
r = self.j.get("rev") r = self.j.get("rev")
if r != None and "url_doc" in r[rev]: if r != None:
if "url_doc" in r[rev]:
return r[rev]["url_doc"] return r[rev]["url_doc"]
fmt = self.j.get("fmt")
if fmt != None and "url_vcc" in fmt:
fmt = fmt["url_doc"]
else:
fmt = None
if fmt != None and "branch" in r[rev]:
return fmt % r[rev]["branch"]
g = self.j.get("github") g = self.j.get("github")
if g != None and "doc_path" in g: if g != None and "doc_path" in g:
s = "https://github.com/" s = "https://github.com/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment