{{{name}}}
-""" + res.add """{{{name}}}
""" + else + res.add """ +{{{name}}} -
+Content
" @@ -354,61 +267,51 @@ class Catalog """ - self.score[mpackage] = score.to_i - return res end @@ -577,18 +426,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 "- "
@@ -618,43 +467,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.
@@ -678,14 +490,18 @@ 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} "
+ res.add "{p.metadata.contributors.length} "
if deps.not_empty then
res.add "{deps[p].greaters.length-1} "
res.add "{deps[p].direct_greaters.length} "
@@ -697,6 +513,10 @@ class Catalog
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"
@@ -711,17 +531,6 @@ 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
-end
-
var model = new Model
var tc = new ToolContext
@@ -759,10 +568,16 @@ 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 = new Set[MPackage]
+for m in mmodules do
+ var p = m.mpackage
+ if p != null then mpackages.add p
end
# Scan packages and compute information
@@ -784,7 +599,7 @@ for p in model.mpackages do
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
@@ -795,6 +610,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 = """
@@ -898,10 +716,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
@@ -920,7 +742,7 @@ index.add catalog.list_best(catalog.score)
if catalog.deps.not_empty then
index.add "Most Required
\n"
var reqs = new Counter[MPackage]
- for p in model.mpackages do
+ for p in mpackages do
reqs[p] = catalog.deps[p].smallers.length - 1
end
index.add catalog.list_best(reqs)
@@ -937,7 +759,7 @@ index.add """
{e} ({projs.length})
\n- \n"
for p in projs do
res.add "
- "
@@ -618,43 +467,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.
@@ -678,14 +490,18 @@ 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" @@ -711,17 +531,6 @@ 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 -end - var model = new Model var tc = new ToolContext @@ -759,10 +568,16 @@ 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 = new Set[MPackage] +for m in mmodules do + var p = m.mpackage + if p != null then mpackages.add p end # Scan packages and compute information @@ -784,7 +599,7 @@ for p in model.mpackages do 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 @@ -795,6 +610,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 = """ @@ -898,10 +716,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 @@ -920,7 +742,7 @@ index.add catalog.list_best(catalog.score) if catalog.deps.not_empty then 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} " + res.add "{p.metadata.contributors.length} " if deps.not_empty then res.add "{deps[p].greaters.length-1} " res.add "{deps[p].direct_greaters.length} " @@ -697,6 +513,10 @@ class Catalog 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 "Most Required
\n" var reqs = new Counter[MPackage] - for p in model.mpackages do + for p in mpackages do reqs[p] = catalog.deps[p].smallers.length - 1 end index.add catalog.list_best(reqs) @@ -937,7 +759,7 @@ index.add """