diff --git a/.gitignore b/.gitignore index ac00b03002..21214558e8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,14 +2,12 @@ build/ packages .buildlog -.project .pub .idea +.settings/ # Or the files created by dart2js. *.dart.js -*.dart.precompiled.js -*.js_ *.js.deps *.js.map diff --git a/.project b/.project new file mode 100644 index 0000000000..67f609f3ca --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ + + + dartdoc + + + + + + com.google.dart.tools.core.dartBuilder + + + + + + com.google.dart.tools.core.dartNature + + + + 1418882159156 + + 30 + + com.google.dart.tools.core.packagesFolderMatcher + + + + diff --git a/bin/dartdoc.dart b/bin/dartdoc.dart index 126603ea2c..d62ec04b81 100644 --- a/bin/dartdoc.dart +++ b/bin/dartdoc.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'package:args/args.dart'; - import 'package:dartdoc/dartdoc.dart'; /// Analyzes Dart files and generates a representation of included libraries, @@ -32,16 +31,15 @@ void _printUsageAndExit(ArgParser parser) { exit(0); } - ArgParser _createArgsParser() { - // TODO: more options to be added +ArgParser _createArgsParser() { + // TODO: more options to be added var parser = new ArgParser(); parser.addOption( 'exclude', help: 'a comma-separated list of library names to ignore'); parser.addOption( - 'url', - help: 'the url where the docs will be hosted.' - 'Used to generate the sitemap.'); + 'url', + help: 'the url where the docs will be hosted (used to generate the sitemap)'); parser.addFlag('help', abbr: 'h', negatable: false, diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart index b1a56a5717..09c2913759 100644 --- a/lib/dartdoc.dart +++ b/lib/dartdoc.dart @@ -49,13 +49,12 @@ class DartDoc { libs.sort(elementCompare); libraries.addAll(libs); - // create the out directory out = new Directory(DEFAULT_OUTPUT_DIRECTORY); if (!out.existsSync()) { out.createSync(recursive: true); } - + generator = new HtmlGenerator(new Package(libraries, _rootDir.path), out, _url); // generate the docs generator.generate(); @@ -107,5 +106,3 @@ class DartDoc { } } - - diff --git a/lib/src/generator.dart b/lib/src/generator.dart index 33e19aa872..ace5dbb21f 100644 --- a/lib/src/generator.dart +++ b/lib/src/generator.dart @@ -16,7 +16,7 @@ import 'model.dart'; /// Generates the HTML files class HtmlGenerator { - + // The sitemap template file final String siteMapTemplate = '/templates/sitemap.xml'; @@ -436,11 +436,11 @@ class HtmlGenerator { print('generating sitemap.xml'); File f = joinFile(new Directory(out.path), ['sitemap.xml']); var script = new File(Platform.script.toFilePath()); - File tmplFile = new File('${script.parent.parent.path}$siteMapTemplate'); + File tmplFile = new File('${script.parent.parent.path}$siteMapTemplate'); var tmpl = tmplFile.readAsStringSync(); // TODO: adjust urls List names = htmlFiles.map((f) => {'name': '$f'}).toList(); - var content = render(tmpl, {'url': url, 'links' : names}); + var content = render(tmpl, {'url': url, 'links' : names}); f.writeAsStringSync(content); } } @@ -545,7 +545,6 @@ class HtmlGeneratorHelper extends Helper { return buf.toString(); } - String createLinkedReturnTypeName(ElementType type) { if (type.returnElement == null) { if (type.returnTypeName != null) { @@ -558,6 +557,3 @@ class HtmlGeneratorHelper extends Helper { } } } - - - diff --git a/lib/src/html_gen.dart b/lib/src/html_gen.dart index 1b3aadb69c..a3da2e46fd 100644 --- a/lib/src/html_gen.dart +++ b/lib/src/html_gen.dart @@ -19,18 +19,17 @@ class HtmlHelper { } void generateHeader() { - // header - startTag('header'); - endTag(); - } + // header + startTag('header'); + endTag(); + } + + void generateFooter() { + // footer + startTag('footer'); + endTag(); + } - void generateFooter() { - // footer - startTag('footer'); - endTag(); - } - - void start({String title, String cssRef}) { startTag('html', newLine: false); writeln(); diff --git a/lib/src/html_utils.dart b/lib/src/html_utils.dart index dc1a01d88c..b9fbf38b76 100644 --- a/lib/src/html_utils.dart +++ b/lib/src/html_utils.dart @@ -155,5 +155,3 @@ String replaceAll(String str, List matchChars, {String htmlEntity, var r } return buf.toString(); } - - diff --git a/lib/src/model.dart b/lib/src/model.dart index dd106f8403..69e20ea580 100644 --- a/lib/src/model.dart +++ b/lib/src/model.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - /// The models used to represent Dart code library dartdoc.models; @@ -12,7 +11,6 @@ import 'html_utils.dart'; import 'model_utils.dart'; import 'package_utils.dart'; - abstract class ModelElement { Element element; @@ -123,9 +121,9 @@ abstract class ModelElement { ExecutableElement ex = (element as ExecutableElement); String retType = generator.createLinkedReturnTypeName(new ElementType(ex.type, library)); - return '${generator.createLinkedName(this)}' - '(${generator.printParams(ex.parameters.map((f)=> - new Parameter(f, library)))})' + return '${generator.createLinkedName(this)}' + '(${generator.printParams(ex.parameters.map((f)=> + new Parameter(f, library)))})' '${retType.isEmpty ? '' : ': $retType'}'; } if (isPropertyInducer) { @@ -354,8 +352,8 @@ class Fnction extends ModelElement { String createLinkedSummary(Helper generator) { String retType = generator.createLinkedReturnTypeName(new ElementType(_func.type, library)); - return '${generator.createLinkedName(this)}' - '(${generator.printParams(_func.parameters.map((f)=> new Parameter(f, library)))})' + return '${generator.createLinkedName(this)}' + '(${generator.printParams(_func.parameters.map((f)=> new Parameter(f, library)))})' '${retType.isEmpty ? '' : ': $retType'}'; } @@ -452,7 +450,7 @@ class Constructor extends ModelElement { if (_constructor.isFactory) { buf.write('factory '); } - buf.write('${_constructor.type.returnType.name}${_constructor.name.isEmpty?'':'.'}' + buf.write('${_constructor.type.returnType.name}${_constructor.name.isEmpty?'':'.'}' '${_constructor.name}' '(${generator.printParams( _constructor.parameters.map((f)=> new Parameter(f, library)))})'); @@ -496,11 +494,11 @@ class Accessor extends ModelElement { buf.write(generator.createLinkedName(this)); buf.write(': '); buf.write(generator.createLinkedReturnTypeName( - new ElementType(_accessor.type, + new ElementType(_accessor.type, new ModelElement.from(_accessor.type.element, library)))); } else { - buf.write('${generator.createLinkedName(this)}(' - '${generator.printParams(_accessor.parameters.map((f)=> + buf.write('${generator.createLinkedName(this)}(' + '${generator.printParams(_accessor.parameters.map((f)=> new Parameter(f,library)))})'); } return buf.toString(); @@ -580,4 +578,3 @@ abstract class Helper { String printParams(List params); String createHrefFor(ModelElement e); } - diff --git a/lib/src/model_utils.dart b/lib/src/model_utils.dart index 1eda179f98..fbc29a8292 100644 --- a/lib/src/model_utils.dart +++ b/lib/src/model_utils.dart @@ -4,9 +4,8 @@ library model_utils; -import 'package:analyzer/src/generated/element.dart'; import 'package:analyzer/src/generated/constant.dart'; - +import 'package:analyzer/src/generated/element.dart'; Object getConstantValue(PropertyInducingElement element) { if (element is ConstFieldElementImpl) { diff --git a/test/all.dart b/test/all.dart index a808d7f918..19b466c21c 100644 --- a/test/all.dart +++ b/test/all.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + library dartdoc.all_tests; import 'template_test.dart' as template_tests; diff --git a/test/template_test.dart b/test/template_test.dart index f7a1daf603..2ecc93e2c3 100644 --- a/test/template_test.dart +++ b/test/template_test.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + library dartdoc.template_test; import 'dart:io'; @@ -5,21 +9,20 @@ import 'dart:io'; import 'package:mustache4dart/mustache4dart.dart'; import 'package:unittest/unittest.dart'; - tests() { group('template', () { var script = new File(Platform.script.toFilePath()); File tmplFile = new File('${script.parent.parent.path}/templates/sitemap.xml'); - + test('sitemap template exists', () { tmplFile.exists().then((t) => expect(t, true)); }); - + var siteMapTmpl = tmplFile.readAsStringSync(); var sitemap = compile(siteMapTmpl); - + test('render', () { - expect(sitemap({'links' : [{'name': 'somefile.html'}]}), + expect(sitemap({'links' : [{'name': 'somefile.html'}]}), ''' @@ -28,10 +31,10 @@ tests() { '''); - }); - - test('substitute multiple links', () { - expect(sitemap({'links' : [{'name': 'somefile.html'}, {'name': 'asecondfile.html'}]}), + }); + + test('substitute multiple links', () { + expect(sitemap({'links' : [{'name': 'somefile.html'}, {'name': 'asecondfile.html'}]}), ''' @@ -43,10 +46,10 @@ tests() { '''); - }); - - test('url and file name', () { - expect(sitemap({'url': 'http://mydoc.com','links' : [{'name': 'somefile.html'}]}), + }); + + test('url and file name', () { + expect(sitemap({'url': 'http://mydoc.com','links' : [{'name': 'somefile.html'}]}), ''' @@ -55,8 +58,6 @@ tests() { '''); - }); - - - }); + }); + }); }