{{{name}}}
-""" + res.add """{{{name}}}
""" + else + res.add """ +{{{name}}} -
+Content
" @@ -354,61 +268,51 @@ class Catalog """ - self.score[mpackage] = score.to_i - return res end @@ -571,18 +427,18 @@ class Catalog # # The list of keys is generated first to allow fast access to the correct ``.
# `id_prefix` is used to give an id to the `` element.
- fun list_by(map: MultiHashMap[String, MPackage], id_prefix: String): Template
+ fun list_by(map: MultiHashMap[Object, MPackage], id_prefix: String): Template
do
var res = new Template
var keys = map.keys.to_a
alpha_comparator.sort(keys)
- var list = [for x in keys do "{x.html_escape}"]
+ var list = [for x in keys do "{x.to_s.html_escape}"]
res.add_list(list, ", ", " and ")
for k in keys do
var projs = map[k].to_a
alpha_comparator.sort(projs)
- var e = k.html_escape
+ var e = k.to_s.html_escape
res.add "{e} ({projs.length})
\n\n"
for p in projs do
res.add "- "
@@ -612,43 +468,6 @@ class Catalog
return res
end
- # Collect more information on a package using the `git` tool.
- fun git_info(mpackage: MPackage)
- do
- var ini = mpackage.ini
- if ini == null then return
-
- # TODO use real git info
- #var repo = ini.get_or_null("upstream.git")
- #var branch = ini.get_or_null("upstream.git.branch")
- #var directory = ini.get_or_null("upstream.git.directory")
-
- var dirpath = mpackage.root.filepath
- if dirpath == null then return
-
- # Collect commits info
- var res = git_run("log", "--no-merges", "--follow", "--pretty=tformat:%ad;%aN <%aE>", "--", dirpath)
- var contributors = new Counter[String]
- var commits = res.split("\n")
- if commits.not_empty and commits.last == "" then commits.pop
- self.commits[mpackage] = commits.length
- for l in commits do
- var s = l.split_once_on(';')
- if s.length != 2 or s.last == "" then continue
-
- # Collect date of last and first commit
- if mpackage.last_date == null then mpackage.last_date = s.first
- mpackage.first_date = s.first
-
- # Count contributors
- contributors.inc(s.last)
- end
- for c in contributors.sort.reverse_iterator do
- mpackage.contributors.add c
- end
-
- end
-
# Produce a HTML table containig information on the packages
#
# `package_page` must have been called before so that information is computed.
@@ -661,7 +480,7 @@ class Catalog
res.add "
name \n"
res.add "maint \n"
res.add "contrib \n"
- if deps.not_empty then
+ if deps.vertices.not_empty then
res.add "reqs \n"
res.add "direct
reqs \n"
res.add "clients \n"
@@ -672,25 +491,33 @@ class Catalog
res.add "methods \n"
res.add "lines \n"
res.add "score \n"
+ res.add "errors \n"
+ res.add "warnings \n"
+ res.add "w/kloc \n"
+ res.add "doc \n"
res.add ""
for p in mpackages do
res.add ""
res.add "{p.name} "
var maint = "?"
- if p.maintainers.not_empty then maint = p.maintainers.first
+ if p.metadata.maintainers.not_empty then maint = p.metadata.maintainers.first.name.html_escape
res.add "{maint} "
- res.add "{p.contributors.length} "
- if deps.not_empty then
- res.add "{deps[p].greaters.length-1} "
- res.add "{deps[p].direct_greaters.length} "
- res.add "{deps[p].smallers.length-1} "
- res.add "{deps[p].direct_smallers.length} "
+ res.add "{p.metadata.contributors.length} "
+ if deps.vertices.not_empty then
+ res.add "{deps.get_all_successors(p).length-1} "
+ res.add "{deps.successors(p).length} "
+ res.add "{deps.get_all_predecessors(p).length-1} "
+ res.add "{deps.predecessors(p).length} "
end
res.add "{mmodules[p]} "
res.add "{mclasses[p]} "
res.add "{mmethods[p]} "
res.add "{loc[p]} "
res.add "{score[p]} "
+ res.add "{errors[p]} "
+ res.add "{warnings[p]} "
+ res.add "{warnings_per_kloc[p]} "
+ res.add "{documentation_score[p]} "
res.add " \n"
end
res.add "\n"
@@ -705,15 +532,22 @@ class Catalog
var piwik_site_id: Int = 1
end
-# Execute a git command and return the result
-fun git_run(command: String...): String
-do
- # print "git {command.join(" ")}"
- var p = new ProcessReader("git", command...)
- var res = p.read_all
- p.close
- p.wait
- return res
+redef class Person
+ redef fun to_html do
+ var res = ""
+ var e = name.html_escape
+ var page = self.page
+ if page != null then
+ res += ""
+ end
+ var gravatar = self.gravatar
+ if gravatar != null then
+ res += " "
+ end
+ res += e
+ if page != null then res += ""
+ return res
+ end
end
var model = new Model
@@ -753,32 +587,22 @@ end
# Get files or groups
var args = tc.option_context.rest
+var mmodules
if opt_no_parse.value then
- modelbuilder.scan_full(args)
+ mmodules = modelbuilder.scan_full(args)
else
- modelbuilder.parse_full(args)
+ mmodules = modelbuilder.parse_full(args)
end
+var mpackages = modelbuilder.model.mpackage_importation_graph.vertices
# Scan packages and compute information
-for p in model.mpackages do
+for p in mpackages do
var g = p.root
assert g != null
modelbuilder.scan_group(g)
-
- # Load the module to process importation information
- if opt_no_parse.value then continue
-
- catalog.deps.add_node(p)
- for gg in p.mgroups do for m in gg.mmodules do
- for im in m.in_importation.direct_greaters do
- var ip = im.mpackage
- if ip == null or ip == p then continue
- catalog.deps.add_edge(p, ip)
- end
- end
end
-if not opt_no_git.value then for p in model.mpackages do
+if not opt_no_git.value then for p in mpackages do
catalog.git_info(p)
end
@@ -789,6 +613,9 @@ end
var out = opt_dir.value or else "catalog.out"
(out/"p").mkdir
+(out/"res").mkdir
+
+catalog.outdir = out
# Generate the css (hard coded)
var css = """
@@ -892,10 +719,14 @@ css.write_to_file(out/"style.css")
# PAGES
-for p in model.mpackages do
+for p in mpackages do
# print p
var f = "p/{p.name}.html"
- catalog.package_page(p).write_to_file(out/f)
+ catalog.package_page(p)
+ catalog.generate_page(p).write_to_file(out/f)
+ # copy ini
+ var ini = p.ini
+ if ini != null then ini.write_to_file(out/"p/{p.name}.ini")
end
# INDEX
@@ -911,11 +742,11 @@ index.add """
index.add "Highlighted Packages
\n"
index.add catalog.list_best(catalog.score)
-if catalog.deps.not_empty then
+if catalog.deps.vertices.not_empty then
index.add "Most Required
\n"
var reqs = new Counter[MPackage]
- for p in model.mpackages do
- reqs[p] = catalog.deps[p].smallers.length - 1
+ for p in mpackages do
+ reqs[p] = catalog.deps.get_all_successors(p).length - 1
end
index.add catalog.list_best(reqs)
end
@@ -931,7 +762,7 @@ index.add """
{e} ({projs.length})
\n- \n"
for p in projs do
res.add "
- "
@@ -612,43 +468,6 @@ class Catalog
return res
end
- # Collect more information on a package using the `git` tool.
- fun git_info(mpackage: MPackage)
- do
- var ini = mpackage.ini
- if ini == null then return
-
- # TODO use real git info
- #var repo = ini.get_or_null("upstream.git")
- #var branch = ini.get_or_null("upstream.git.branch")
- #var directory = ini.get_or_null("upstream.git.directory")
-
- var dirpath = mpackage.root.filepath
- if dirpath == null then return
-
- # Collect commits info
- var res = git_run("log", "--no-merges", "--follow", "--pretty=tformat:%ad;%aN <%aE>", "--", dirpath)
- var contributors = new Counter[String]
- var commits = res.split("\n")
- if commits.not_empty and commits.last == "" then commits.pop
- self.commits[mpackage] = commits.length
- for l in commits do
- var s = l.split_once_on(';')
- if s.length != 2 or s.last == "" then continue
-
- # Collect date of last and first commit
- if mpackage.last_date == null then mpackage.last_date = s.first
- mpackage.first_date = s.first
-
- # Count contributors
- contributors.inc(s.last)
- end
- for c in contributors.sort.reverse_iterator do
- mpackage.contributors.add c
- end
-
- end
-
# Produce a HTML table containig information on the packages
#
# `package_page` must have been called before so that information is computed.
@@ -661,7 +480,7 @@ class Catalog
res.add "
name \n" res.add "maint \n" res.add "contrib \n" - if deps.not_empty then + if deps.vertices.not_empty then res.add "reqs \n" res.add "direct \n" res.add "
reqsclients \n" @@ -672,25 +491,33 @@ class Catalog res.add "methods \n" res.add "lines \n" res.add "score \n" + res.add "errors \n" + res.add "warnings \n" + res.add "w/kloc \n" + res.add "doc \n" res.add "" for p in mpackages do res.add "" res.add " \n" end res.add "\n" @@ -705,15 +532,22 @@ class Catalog var piwik_site_id: Int = 1 end -# Execute a git command and return the result -fun git_run(command: String...): String -do - # print "git {command.join(" ")}" - var p = new ProcessReader("git", command...) - var res = p.read_all - p.close - p.wait - return res +redef class Person + redef fun to_html do + var res = "" + var e = name.html_escape + var page = self.page + if page != null then + res += "" + end + var gravatar = self.gravatar + if gravatar != null then + res += " " + end + res += e + if page != null then res += "" + return res + end end var model = new Model @@ -753,32 +587,22 @@ end # Get files or groups var args = tc.option_context.rest +var mmodules if opt_no_parse.value then - modelbuilder.scan_full(args) + mmodules = modelbuilder.scan_full(args) else - modelbuilder.parse_full(args) + mmodules = modelbuilder.parse_full(args) end +var mpackages = modelbuilder.model.mpackage_importation_graph.vertices # Scan packages and compute information -for p in model.mpackages do +for p in mpackages do var g = p.root assert g != null modelbuilder.scan_group(g) - - # Load the module to process importation information - if opt_no_parse.value then continue - - catalog.deps.add_node(p) - for gg in p.mgroups do for m in gg.mmodules do - for im in m.in_importation.direct_greaters do - var ip = im.mpackage - if ip == null or ip == p then continue - catalog.deps.add_edge(p, ip) - end - end end -if not opt_no_git.value then for p in model.mpackages do +if not opt_no_git.value then for p in mpackages do catalog.git_info(p) end @@ -789,6 +613,9 @@ end var out = opt_dir.value or else "catalog.out" (out/"p").mkdir +(out/"res").mkdir + +catalog.outdir = out # Generate the css (hard coded) var css = """ @@ -892,10 +719,14 @@ css.write_to_file(out/"style.css") # PAGES -for p in model.mpackages do +for p in mpackages do # print p var f = "p/{p.name}.html" - catalog.package_page(p).write_to_file(out/f) + catalog.package_page(p) + catalog.generate_page(p).write_to_file(out/f) + # copy ini + var ini = p.ini + if ini != null then ini.write_to_file(out/"p/{p.name}.ini") end # INDEX @@ -911,11 +742,11 @@ index.add """ index.add "{p.name} " var maint = "?" - if p.maintainers.not_empty then maint = p.maintainers.first + if p.metadata.maintainers.not_empty then maint = p.metadata.maintainers.first.name.html_escape res.add "{maint} " - res.add "{p.contributors.length} " - if deps.not_empty then - res.add "{deps[p].greaters.length-1} " - res.add "{deps[p].direct_greaters.length} " - res.add "{deps[p].smallers.length-1} " - res.add "{deps[p].direct_smallers.length} " + res.add "{p.metadata.contributors.length} " + if deps.vertices.not_empty then + res.add "{deps.get_all_successors(p).length-1} " + res.add "{deps.successors(p).length} " + res.add "{deps.get_all_predecessors(p).length-1} " + res.add "{deps.predecessors(p).length} " end res.add "{mmodules[p]} " res.add "{mclasses[p]} " res.add "{mmethods[p]} " res.add "{loc[p]} " res.add "{score[p]} " + res.add "{errors[p]} " + res.add "{warnings[p]} " + res.add "{warnings_per_kloc[p]} " + res.add "{documentation_score[p]} " res.add "Highlighted Packages
\n" index.add catalog.list_best(catalog.score) -if catalog.deps.not_empty then +if catalog.deps.vertices.not_empty then index.add "Most Required
\n" var reqs = new Counter[MPackage] - for p in model.mpackages do - reqs[p] = catalog.deps[p].smallers.length - 1 + for p in mpackages do + reqs[p] = catalog.deps.get_all_successors(p).length - 1 end index.add catalog.list_best(reqs) end @@ -931,7 +762,7 @@ index.add """