Skip to content

Commit

Permalink
Merge pull request #37 from dart-lang/devoncarew_bootstrap_changes
Browse files Browse the repository at this point in the history
partial upgrade to bootstrap 3.0
  • Loading branch information
keertip committed Jan 5, 2015
2 parents 2c123f8 + bc0906b commit a04cde4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
33 changes: 21 additions & 12 deletions lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import 'model.dart';

/// Generates the HTML files
class HtmlGenerator {

// The sitemap template file
final String siteMapTemplate = '/templates/sitemap.xml';
static final String siteMapTemplate = '/templates/sitemap.xml';

static final String bootstrapOverrides = '''
body {
margin: 8px;
}''';

Directory out;
Package package;
Expand Down Expand Up @@ -53,20 +57,21 @@ class HtmlGenerator {
htmlFiles.add(fileName);
print('generating ${f.path}');

html.start(title: 'Package ${packageName}', cssRef: css.getCssName());
html.start(title: 'Package ${packageName}', cssRef: css.getCssName(),
inlineStyle: bootstrapOverrides);
html.generateHeader();
html.startTag('div', attributes: "class='container'", newLine: false);
html.writeln();
html.startTag('div', attributes: "class='row'", newLine: false);
html.writeln();
html.startTag('div', attributes: "class='span3'");
html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"');
html.startTag('div', attributes: "class='col-md-3'");
html.startTag('ul', attributes: 'class="nav nav-pills nav-stacked"');
html.startTag('li', attributes: 'class="active"', newLine: false);
html.write('<a href="${packageName}">' '<i class="chevron-nav icon-white icon-chevron-right"></i> ' '${packageName}-${packageVersion}</a>');
html.endTag(); //li
html.endTag(); //ul
html.endTag();
html.startTag('div', attributes: "class='span9'");
html.startTag('div', attributes: "class='col-md-9'");
html.tag('h1', contents: packageName);
html.writeln('<hr>');
html.write(packageDesc);
Expand All @@ -92,7 +97,8 @@ class HtmlGenerator {
print('generating ${f.path}');
htmlFiles.add(fileName);
html = new HtmlHelper();
html.start(title: 'Library ${library.name}', cssRef: css.getCssName());
html.start(title: 'Library ${library.name}', cssRef: css.getCssName(),
inlineStyle: bootstrapOverrides);

html.generateHeader();

Expand All @@ -102,16 +108,16 @@ class HtmlGenerator {
html.writeln();

// left nav
html.startTag('div', attributes: "class='span3'");
html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"');
html.startTag('div', attributes: "class='col-md-3'");
html.startTag('ul', attributes: 'class="nav nav-pills nav-stacked"');
html.startTag('li', attributes: 'class="active"', newLine: false);
html.write('<a href="${_getFileNameFor(library)}">' '<i class="chevron-nav icon-white icon-chevron-right"></i> ' '${library.name}</a>');
html.endTag(); // li
html.endTag(); // ul.nav
html.endTag(); // div.span3
html.endTag(); // div.col-md-3

// main content
html.startTag('div', attributes: "class='span9'");
html.startTag('div', attributes: "class='col-md-9'");

html.tag('h1', contents: library.name);

Expand Down Expand Up @@ -162,7 +168,7 @@ class HtmlGenerator {

html.writeln('<hr>');

html.endTag(); // div.span9
html.endTag(); // div.col-md-9

html.endTag(); // div.row

Expand Down Expand Up @@ -329,6 +335,9 @@ class HtmlGenerator {
}

String createIconFor(ModelElement e) {
// TODO: This icons need to be upgraded to bootstrap 3.0 - something like:
// <span class="glyphicon glyphicon-search"></span>

if (e.isPropertyAccessor) {
Accessor a = (e as Accessor);
if (a.isGetter) {
Expand Down
8 changes: 6 additions & 2 deletions lib/src/html_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HtmlHelper {
endTag();
}

void start({String title, String cssRef}) {
void start({String title, String cssRef, String inlineStyle}) {
startTag('html', newLine: false);
writeln();
startTag('head');
Expand All @@ -42,7 +42,11 @@ class HtmlHelper {
if (cssRef != null) {
writeln('<link href="${cssRef}" rel="stylesheet" media="screen">');
}
// head
if (inlineStyle != null) {
startTag('style');
writeln(inlineStyle);
endTag();
}
endTag();
writeln();
startTag('body', newLine: false);
Expand Down

0 comments on commit a04cde4

Please sign in to comment.