use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CeylonDocTool method doc.
private void doc(Module module) throws IOException {
Writer rootWriter = openWriter(getObjectFile(module));
try {
ModuleDoc moduleDoc = new ModuleDoc(this, rootWriter, module);
moduleDoc.generate();
for (Package pkg : getPackages(module)) {
if (pkg.getMembers().isEmpty()) {
continue;
}
// document the package
if (!isRootPackage(module, pkg)) {
Writer packageWriter = openWriter(getObjectFile(pkg));
try {
new PackageDoc(this, packageWriter, pkg).generate();
} finally {
packageWriter.close();
}
}
// document its members
for (Declaration decl : pkg.getMembers()) {
doc(decl);
}
if (pkg.getNameAsString().equals(AbstractModelLoader.CEYLON_LANGUAGE)) {
docNothingType(pkg);
}
}
} finally {
rootWriter.close();
}
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CeylonDocTool method copySourceFiles.
private void copySourceFiles() throws FileNotFoundException, IOException {
for (PhasedUnit pu : phasedUnits) {
Package pkg = pu.getUnit().getPackage();
if (!shouldInclude(pkg)) {
continue;
}
File file = new File(getFolder(pu.getPackage()), pu.getUnitFile().getName() + ".html");
File dir = file.getParentFile();
if (!dir.exists() && !dir.mkdirs()) {
throw new IOException(CeylondMessages.msg("error.couldNotCreateDirectory", file));
}
Writer writer = openWriter(file);
try {
Markup markup = new Markup(writer);
markup.write("<!DOCTYPE html>");
markup.open("html xmlns='http://www.w3.org/1999/xhtml'");
markup.open("head");
markup.tag("meta charset='UTF-8'");
markup.around("title", pu.getUnit().getFilename());
markup.tag("link href='" + getResourceUrl(pkg, "favicon.ico") + "' rel='shortcut icon'");
markup.tag("link href='" + getResourceUrl(pkg, "ceylon.css") + "' rel='stylesheet' type='text/css'");
markup.tag("link href='" + getResourceUrl(pkg, "ceylondoc.css") + "' rel='stylesheet' type='text/css'");
markup.tag("link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'");
markup.open("script type='text/javascript'");
markup.write("var resourceBaseUrl = '" + getResourceUrl(pkg, "") + "'");
markup.close("script");
markup.around("script src='" + getResourceUrl(pkg, "jquery-1.8.2.min.js") + "' type='text/javascript'");
markup.around("script src='" + getResourceUrl(pkg, "rainbow.min.js") + "' type='text/javascript'");
markup.around("script src='" + getResourceUrl(pkg, "rainbow.linenumbers.js") + "' type='text/javascript'");
markup.around("script src='" + getResourceUrl(pkg, "ceylon.js") + "' type='text/javascript'");
markup.around("script src='" + getResourceUrl(pkg, "ceylondoc.js") + "' type='text/javascript'");
markup.close("head");
markup.open("body", "pre data-language='ceylon' style='font-family: Inconsolata, Monaco, Courier, monospace'");
// XXX source char encoding
BufferedReader input = new BufferedReader(new InputStreamReader(pu.getUnitFile().getInputStream()));
try {
String line = input.readLine();
while (line != null) {
markup.text(line, "\n");
line = input.readLine();
}
} finally {
input.close();
}
markup.close("pre", "body", "html");
} finally {
writer.close();
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class PackageDoc method writeSubpackages.
private void writeSubpackages() throws IOException {
if (!sharingPageWithModule) {
List<Package> subpackages = new ArrayList<Package>();
for (Package p : module.getPackages()) {
if (p.getName().size() == pkg.getName().size() + 1 && p.getNameAsString().startsWith(pkg.getNameAsString()) && tool.shouldInclude(p)) {
subpackages.add(p);
}
}
Collections.sort(subpackages, ReferenceableComparatorByName.INSTANCE);
writePackagesTable("Subpackages", subpackages);
}
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CeylonDoc method writeBy.
protected final void writeBy(Object obj) throws IOException {
List<Annotation> annotations;
if (obj instanceof Declaration) {
annotations = ((Declaration) obj).getAnnotations();
} else if (obj instanceof Module) {
annotations = ((Module) obj).getAnnotations();
} else if (obj instanceof Package) {
annotations = ((Package) obj).getAnnotations();
} else {
throw new IllegalArgumentException();
}
List<String> authors = new ArrayList<>();
for (Annotation annotation : annotations) {
if (annotation.getName().equals("by")) {
for (String author : annotation.getPositionalArguments()) {
authors.add(author);
}
}
}
if (!authors.isEmpty()) {
open("div class='by section'");
around("span class='title'", "By: ");
around("span class='value'", Util.join(", ", authors));
close("div");
}
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CeylonDocTool method getPackages.
List<Package> getPackages(Module module) {
List<Package> packages = new ArrayList<Package>();
for (Package pkg : module.getPackages()) {
if (shouldInclude(pkg)) {
packages.add(pkg);
}
}
Collections.sort(packages, ReferenceableComparatorByName.INSTANCE);
return packages;
}
Aggregations