summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2019-02-25 15:58:53 +0900
committerKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2019-04-09 14:59:46 +0900
commit0ac23cddb502bdf9180e94623f42f20ae999a4c8 (patch)
treec6f838e7fbd32e139d56d3bfc36a4b27655474f8
parent39f25bf805115fabba4290328492aa23db0d7013 (diff)
Add html support
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
-rw-r--r--.config.sample2
-rw-r--r--.gitignore2
-rw-r--r--Makefile63
-rw-r--r--README.md7
-rwxr-xr-xscripts/html.py468
5 files changed, 542 insertions, 0 deletions
diff --git a/.config.sample b/.config.sample
index a12a486..2127c03 100644
--- a/.config.sample
+++ b/.config.sample
@@ -1,5 +1,7 @@
viewer:less -RXE
+git-linux:/home/morimoto/WORK/linux
+
# color = escape sequence
key:33
status:01;46
diff --git a/.gitignore b/.gitignore
index 94ba4f5..61f189e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
.config
scripts/__pycache__/
+index.html
+html
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1dfe8b1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,63 @@
+CMD = ./scripts/html.py
+FOLDERS = $(subst ./,,$(shell cd ./projects; find -type d))
+DST = $(subst yaml,html,$(subst projects,html,${SRC}))
+MEMBER = BSP Geert Jacopo Kaneko Kieran Laurent Magnus Marek Morimoto Niklas Shimoda Simon Ulrich Wolfram
+STATUS = New Active Blocked Paused Done Abandoned
+SPF = menu subindex body
+
+all: summary spf files index.html members statuss
+
+summary:
+ @for folder in ${FOLDERS}; do\
+ mkdir -p ./html/$${folder};\
+ make -s DIR=$${folder} ./html/$${folder}/summary.html;\
+ done;
+
+html/${DIR}/summary.html: ./projects/${DIR} ${CMD}
+ @echo html/${DIR}/summary.html
+ ${CMD} summary projects/${DIR} > ./html/${DIR}/summary.html; \
+
+spf:
+ @for cmd in ${SPF}; do\
+ make -s TGT=$${cmd} html/$${cmd}.html;\
+ done;
+
+${SPF:%=html/%.html}: projects/* ${CMD}
+ @echo $@
+ ${CMD} ${TGT} > $@
+
+index.html: ${CMD}
+ @echo $@
+ @${CMD} index > $@
+
+files:
+ @for file in $(shell ./scripts/find.py -a); do\
+ make -s SRC=$${file} file;\
+ done;
+
+file:
+ @make -s SRC=${SRC} DST=${DST} TGT=task ${DST}
+
+members:
+ @for mem in ${MEMBER}; do\
+ make -s MEM=$${mem} member;\
+ done;
+
+member:
+ @make -s SRC="$(shell ./scripts/find.py -a ${MEM})" DST=./html/${MEM}.html TGT="member ${MEM}" ./html/${MEM}.html
+
+statuss:
+ @for status in ${STATUS}; do\
+ make -s STA=$${status} status;\
+ done;
+
+status:
+ @make -s SRC="$(shell ./scripts/find.py -s ${STA})" DST=./html/${STA}.html TGT="status ${STA}" ./html/${STA}.html
+
+${DST}: ${SRC} ${CMD}
+ @echo "${DST}"
+ ${CMD} ${TGT} ${SRC} > $@
+
+clean:
+ @rm -fr html
+ @rm -fr *.html
diff --git a/README.md b/README.md
index 2410b8a..6f40bf2 100644
--- a/README.md
+++ b/README.md
@@ -46,3 +46,10 @@ You need to have **.config** file. You can copy sample .config, and edit it
* -f : show with file name
* -r : show with relationships
* --oneline : show one line
+
+# HTML
+
+## How to create HTML ?
+It is easy ! just "make"
+You can find index.html on top of periject folder
+But, You need to have **.config** file. You can copy sample .config, and edit it
diff --git a/scripts/html.py b/scripts/html.py
new file mode 100755
index 0000000..96c6108
--- /dev/null
+++ b/scripts/html.py
@@ -0,0 +1,468 @@
+#! /usr/bin/env python3
+#===============================
+#
+# html
+#
+# 2019/02/18 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+#===============================
+import sys
+import os
+
+import base
+import find
+import view
+
+#====================================
+#
+# html
+#
+#====================================
+class html(base.base):
+
+ __head = 0
+ __noclose = ["input",
+ "frame",
+ "link",
+ "br",
+ ]
+
+ #--------------------
+ # option
+ #--------------------
+ def option(self, dic):
+ if (dic):
+ self.dic.update(dic)
+
+ #--------------------
+ # __init__
+ #--------------------
+ def __init__(self, mark, dic = None):
+ super().__init__()
+
+ self.dic = {}
+ self.mark = mark
+ self.option(dic)
+ self.txt = ""
+
+ #--------------------
+ # open
+ #--------------------
+ def open(self, ret = 0):
+
+ self.txt = ""
+
+ if (ret):
+ for i in range(html.__head):
+ self.txt += "\t"
+
+ self.txt += "<{}".format(self.mark)
+ for d in self.dic:
+ self.txt += " {}=\"{}\"".format(d, self.dic[d])
+ self.txt += ">"
+ html.__head += 1
+
+ #--------------------
+ # close
+ #--------------------
+ def close(self, ret = 0):
+ html.__head -= 1
+ # no end-mark
+ if (self.mark in html.__noclose):
+ return
+
+ if (ret):
+ for i in range(html.__head):
+ self.txt += "\t"
+ self.txt += "</{}>".format(self.mark)
+
+ #--------------------
+ # text
+ #--------------------
+ def text(self, txt = ""):
+ self.open()
+ self.txt += txt
+ self.close()
+ return self.txt
+
+ #--------------------
+ # print
+ #--------------------
+ def print(self, txt = ""):
+
+ self.open(1)
+ self.txt += txt
+ self.close(0)
+ print(self.txt)
+
+ #--------------------
+ # for with
+ #--------------------
+ def __enter__(self):
+ self.open(1)
+ print(self.txt)
+ self.txt = ""
+ return self
+ def __exit__(self, exception_type, exception_value, traceback):
+ self.close(1)
+ print(self.txt)
+ self.txt = ""
+
+#====================================
+#
+# periject_html
+#
+#====================================
+class periject_html(base.base):
+
+ def __init__(self):
+ super().__init__()
+ self.git = self.config("git-linux")
+
+ def git_title(self, id):
+ return self.run("git -C {} log -1 {} --format=%s".format(self.git, id))
+
+ def bsp_url(self, id):
+ return "https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/commit/?id={}".format(id)
+
+ def upstream_url(self, id):
+ return "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id={}".format(id)
+
+ #--------------------
+ # index
+ #--------------------
+ def index(self):
+ # | | |
+ # |menu|body|
+ # | | |
+ with html("frameset", {"cols":"200,*"}):
+ html("frame", {"src":"./html/menu.html", "name":"menu"}).print()
+ html("frame", {"src":"./html/subindex.html", "name":"body"}).print()
+
+ #--------------------
+ # summary
+ #--------------------
+ def subindex(self):
+ # -------
+ # summary
+ # -------
+ # body
+ # -------
+ with html("frameset", {"rows":"300,*"}):
+ html("frame", {"src":"./summary.html", "name":"summary"}).print()
+ html("frame", {"src":"./body.html", "name":"subbody"}).print()
+
+
+ #--------------------
+ # summary
+ #--------------------
+ def __summary(self, title, dir, files):
+ # -------
+ # summary
+ # -------
+ #
+ # -------
+ html("h2").print(title)
+ with html("table", {"border":"1"}):
+ # | file-name | status | assignee | title |
+ for file in files:
+ v = view.viewer([file])
+ v.set_data(file)
+ f = os.path.basename(file)
+
+ subbody = html("a", {"target":"subbody"})
+ summary = html("a", {"target":"summary"})
+ with html("tr"):
+ subbody.option({"href":os.path.relpath(file.replace("yaml", "html").replace("projects", "html"), dir)})
+ html("td").print(subbody.text(os.path.basename(file).replace(".yaml", "")))
+
+ status = v.get_data("status")
+ summary.option({"href":os.path.relpath("{}/html/{}.html".format(self.top(), status), dir)})
+ html("td").print(summary.text(status))
+
+ assignee = v.get_data("assignee")
+ summary.option({"href":os.path.relpath("{}/html/{}.html".format(self.top(), assignee), dir)})
+ html("td").print(summary.text(assignee))
+
+ html("td").print(v.get_data("title"))
+
+ #--------------------
+ # summary
+ #--------------------
+ def summary(self, argv):
+
+ dir = os.path.normpath(argv[0])
+
+ # -------
+ # summary
+ # -------
+ #
+ # -------
+ self.__summary(dir, self.top() + "/" + dir, find.find([dir]).get())
+
+ #--------------------
+ # menu_folder
+ #--------------------
+ def menu_folder(self, current):
+ folders = self.runl("cd {}; ls -F | grep /".format(current))
+ path = current.replace("./projects", ".")
+ link = html("a", {"target":"summary",
+ "href":"{}/summary.html".format(path)})
+
+ html("li").print(link.text(os.path.basename(current)))
+
+ if (not folders):
+ return
+
+ with html("ul"):
+ for folder in folders:
+ dir = os.path.basename(folder)
+ self.menu_folder("{}/{}".format(current, folder[:-1]))
+
+ #--------------------
+ # menu_assignee
+ #--------------------
+ def menu_assignee(self):
+ # from project.schema.yaml
+ with html("ul"):
+ for assignee in ['BSP', 'Geert', 'Jacopo', 'Kaneko', 'Kieran', 'Laurent', 'Magnus', 'Marek',
+ 'Morimoto', 'Niklas', 'Shimoda', 'Simon', 'Ulrich', 'Wolfram']:
+ html("li").print(html("a", {"target":"summary",
+ "href":"./{}.html".format(assignee)}).text(assignee))
+
+ #--------------------
+ # menu_status
+ #--------------------
+ def menu_status(self):
+ # from project.schema.yaml
+ with html("ul"):
+ for status in ['New', 'Active', 'Blocked', 'Paused', 'Done', 'Abandoned']:
+ html("li").print(html("a", {"target":"summary",
+ "href":"./{}.html".format(status)}).text(status))
+
+ #--------------------
+ # menu
+ #--------------------
+ def menu(self):
+
+ with html("body"):
+ html("h1").print("Folder")
+ with html("ul"):
+ self.menu_folder("./projects")
+
+ html("h1").print("Assignee")
+ self.menu_assignee()
+
+ html("h1").print("Status")
+ self.menu_status()
+
+ #--------------------
+ # body
+ #--------------------
+ def body(self):
+ with html("body"):
+ html("div").print("select tasks from menu")
+
+ #--------------------
+ # task_status
+ #--------------------
+ def task_status(self, v):
+ dir = os.path.dirname(v.file)
+ assignee = v.get_data("assignee")
+ status = v.get_data("status")
+
+ with html("table", {"border":"1"}):
+ with html("tr"):
+ html("td").print("status")
+ html("td").print(html("a", {"target":"summary",
+ "href":os.path.relpath("{}/html/{}.html".format(self.top(), status), dir)}).text(status))
+ with html("tr"):
+ html("td").print("assignee")
+ html("td").print(html("a", {"target":"summary",
+ "href":os.path.relpath("{}/html/{}.html".format(self.top(), assignee), dir)}).text(assignee))
+ with html("tr"):
+ html("td").print("key")
+ html("td").print(v.get_data("key"))
+
+ #--------------------
+ # _task_relation
+ #--------------------
+ def _task_relation(self, relationship, v, item):
+
+ current_dir = os.path.dirname(v.file)
+ related_file = v.get_related_file(relationship[item])
+
+ if (not os.path.exists(related_file)):
+ with html("tr"):
+ html("td").print(item)
+ html("td").print("Unknown({})".format(related_file))
+ return
+
+ rv = view.viewer([related_file])
+ rv.set_data(related_file)
+ with html("tr"):
+ html("td").print(item)
+ html("td").print(html("a", {"href":
+ os.path.relpath(related_file.replace("projects", "html").replace("yaml", "html"), current_dir)}).text(rv.get_data("title")))
+
+ #--------------------
+ # task_relation
+ #--------------------
+ def task_relation(self, v):
+
+ relationships = v.get_data("relationships")
+ if (not relationships):
+ return
+
+ current_dir = os.path.dirname(v.file)
+
+ with html("table", {"border":"1"}):
+ for relationship in relationships:
+ if ("parent" in relationship):
+ self._task_relation(relationship, v, "parent")
+ if ("depends" in relationship):
+ self._task_relation(relationship, v, "depends")
+ if ("blocks" in relationship):
+ self._task_relation(relationship, v, "blocks")
+
+ #--------------------
+ # task_head
+ #--------------------
+ def task_head(self, v):
+
+ with html("table"):
+ with html("tr"):
+ with html("td"):
+ self.task_status(v)
+ with html("td"):
+ self.task_relation(v)
+
+ #--------------------
+ # task_commit_bsp
+ #--------------------
+ def task_commit_bsp(self, v):
+
+ with html("ul"):
+ for bsp in v.get_data("bsp-commits"):
+ html("li").print(html("a", {"href":self.bsp_url(bsp)}).text(self.git_title(bsp)))
+
+ #--------------------
+ # __task_commit_upstream
+ #--------------------
+ def __task_commit_upstream(self, v, upstream, item):
+ if (not item in upstream):
+ return
+
+ commit = upstream[item]
+
+ with html("tr"):
+ html("td").print(item)
+ html("td").print(html("a", {"href":self.upstream_url(commit)}).text(self.git_title(commit)))
+
+ #--------------------
+ # task_commit_upstream
+ #--------------------
+ def task_commit_upstream(self, v):
+ upstream = v.get_data("upstream")
+
+ with html("table"):
+ for up in upstream:
+ self.__task_commit_upstream(v, up, "torvalds")
+ for up in upstream:
+ self.__task_commit_upstream(v, up, "next")
+
+ #--------------------
+ # task_commit
+ #--------------------
+ def task_commit(self, v):
+
+ bsp = v.get_data("bsp-commits")
+ if (not bsp):
+ return
+
+ with html("table", {"border":"1"}):
+ with html("tr"):
+ html("th").print("BSP")
+ html("th").print("upstream")
+ with html("tr"):
+ with html("td"):
+ self.task_commit_bsp(v)
+ with html("td"):
+ self.task_commit_upstream(v)
+
+ #--------------------
+ # task_comment
+ #--------------------
+ def task_comment(self, v):
+ comments = v.get_data("comments")
+ if (not comments):
+ return
+
+ with html("ul"):
+ for comment in comments:
+ html("li").print(comment)
+
+ #--------------------
+ # task
+ #--------------------
+ def task(self, argv):
+ v = view.viewer([argv[0]])
+ v.set_data(argv[0])
+
+ with html("body"):
+ html("h1").print(v.get_data("title"))
+ self.task_head(v)
+ self.task_commit(v)
+ self.task_comment(v)
+
+ #--------------------
+ # member
+ #--------------------
+ def member(self, argv):
+
+ mem = argv.pop(0)
+
+ with html("body"):
+ self.__summary(mem, "{}/html".format(self.top()), argv)
+
+ #--------------------
+ # print
+ #--------------------
+ def print(self, argv):
+
+ # remove this script
+ argv.pop(0)
+
+ cmd = sys.argv.pop(0)
+ with html("html"):
+ if (cmd == "index"):
+ # html.py index
+ self.index()
+ elif(cmd == "subindex"):
+ # html.py subindex
+ self.subindex()
+ elif (cmd == "body"):
+ # html.py body
+ self.body()
+ elif (cmd == "summary"):
+ # html.py summary projects/linux/io
+ self.summary(sys.argv)
+ elif (cmd == "menu"):
+ # html.py menu
+ self.menu()
+ elif (cmd == "task"):
+ # html.py task projects/linux/io/xxx.yaml
+ self.task(sys.argv)
+ elif (cmd == "member"):
+ # ./script/find.py -a Wolfram | xargs ./script/html.py menber Wolfram
+ self.member(sys.argv)
+ elif (cmd == "status"):
+ # ./script/find.py -s Active | xargs ./script/html.py status Active
+ self.member(sys.argv)
+
+#====================================
+#
+# As command
+#
+#====================================
+if __name__=='__main__':
+ periject_html().print(sys.argv)