| Index: pkg/docgen/lib/docgen.dart
|
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
|
| index 7c4bde879016a3eb2e5fb9b8f1f27e1303a14d16..e90810e2652d8b85406985980dfc673dac3f4314 100644
|
| --- a/pkg/docgen/lib/docgen.dart
|
| +++ b/pkg/docgen/lib/docgen.dart
|
| @@ -37,297 +37,296 @@ import '../../../sdk/lib/_internal/libraries.dart';
|
|
|
| var logger = new Logger('Docgen');
|
|
|
| -const String usage = 'Usage: dart docgen.dart [OPTIONS] [fooDir/barFile]';
|
| +const String USAGE = 'Usage: dart docgen.dart [OPTIONS] [fooDir/barFile]';
|
|
|
| -/**
|
| - * This class documents a list of libraries.
|
| - */
|
| -class Docgen {
|
| +/// Current library being documented to be used for comment links.
|
| +LibraryMirror _currentLibrary;
|
|
|
| - /// Libraries to be documented.
|
| - List<LibraryMirror> _libraries;
|
| +/// Current class being documented to be used for comment links.
|
| +ClassMirror _currentClass;
|
|
|
| - /// Current library being documented to be used for comment links.
|
| - LibraryMirror _currentLibrary;
|
| -
|
| - /// Current class being documented to be used for comment links.
|
| - ClassMirror _currentClass;
|
| -
|
| - /// Current member being documented to be used for comment links.
|
| - MemberMirror _currentMember;
|
| -
|
| - /// Resolves reference links in doc comments.
|
| - markdown.Resolver linkResolver;
|
| -
|
| - /// Package directory of directory being analyzed.
|
| - String packageDir;
|
| -
|
| - bool outputToYaml;
|
| - bool outputToJson;
|
| - bool includePrivate;
|
| - /// State for whether imported SDK libraries should also be outputted.
|
| - bool includeSdk;
|
| - /// State for whether all SDK libraries should be outputted.
|
| - bool parseSdk;
|
| -
|
| - /**
|
| - * Docgen constructor initializes the link resolver for markdown parsing.
|
| - * Also initializes the command line arguments.
|
| - */
|
| - Docgen(ArgResults argResults) {
|
| - setCommandLineArguments(argResults);
|
| -
|
| - this.linkResolver = (name) =>
|
| - fixReference(name, _currentLibrary, _currentClass, _currentMember);
|
| -
|
| - getMirrorSystem(argResults.rest).then(setLibraries);
|
| - }
|
| +/// Current member being documented to be used for comment links.
|
| +MemberMirror _currentMember;
|
|
|
| - void setCommandLineArguments(ArgResults argResults) {
|
| - outputToYaml = argResults['yaml'] || argResults['output-format'] == 'yaml';
|
| - outputToJson = argResults['json'] || argResults['output-format'] == 'json';
|
| - if (outputToYaml && outputToJson) {
|
| - throw new ArgumentError('Cannot have contradictory output flags.');
|
| - }
|
| - outputToYaml = outputToYaml || !outputToJson;
|
| - includePrivate = argResults['include-private'];
|
| - parseSdk = argResults['parse-sdk'];
|
| - includeSdk = parseSdk || argResults['include-sdk'];
|
| - }
|
| -
|
| - List<String> listLibraries(List<String> args) {
|
| - // TODO(janicejl): At the moment, only have support to have either one file,
|
| - // or one directory. This is because there can only be one package directory
|
| - // since only one docgen is created per run.
|
| - if (args.length != 1) throw new UnsupportedError(usage);
|
| - var libraries = new List<String>();
|
| - var type = FileSystemEntity.typeSync(args[0]);
|
| -
|
| - if (type == FileSystemEntityType.FILE) {
|
| - libraries.add(path.absolute(args[0]));
|
| - logger.info('Added to libraries: ${libraries.last}');
|
| - } else {
|
| - libraries.addAll(listDartFromDir(args[0]));
|
| - }
|
| - logger.info('Package Directory: $packageDir');
|
| - return libraries;
|
| - }
|
| +/// Resolves reference links in doc comments.
|
| +markdown.Resolver linkResolver;
|
|
|
| - List<String> listDartFromDir(String args) {
|
| - var files = listDir(args, recursive: true);
|
| - packageDir = files.firstWhere((f) =>
|
| - f.endsWith('/pubspec.yaml'), orElse: () => '');
|
| - if (packageDir != '') packageDir = path.dirname(packageDir) + '/packages';
|
| - return files.where((f) =>
|
| - f.endsWith('.dart') && !f.contains('/packages')).toList()
|
| - ..forEach((lib) => logger.info('Added to libraries: $lib'));
|
| - }
|
| +/// Package directory of directory being analyzed.
|
| +String packageDir;
|
|
|
| - List<String> listSdk() {
|
| - var sdk = new List<String>();
|
| - LIBRARIES.forEach((String name, LibraryInfo info) {
|
| - if (info.documented) {
|
| - sdk.add('dart:$name');
|
| - logger.info('Add to SDK: ${sdk.last}');
|
| - }
|
| - });
|
| - return sdk;
|
| - }
|
| +bool outputToYaml;
|
| +bool outputToJson;
|
| +bool includePrivate;
|
| +/// State for whether imported SDK libraries should also be outputted.
|
| +bool includeSdk;
|
| +/// State for whether all SDK libraries should be outputted.
|
| +bool parseSdk;
|
| +
|
| +/**
|
| + * Docgen constructor initializes the link resolver for markdown parsing.
|
| + * Also initializes the command line arguments.
|
| + */
|
| +void docgen(ArgResults argResults) {
|
| + _setCommandLineArguments(argResults);
|
|
|
| - void setLibraries(MirrorSystem mirrorSystem) {
|
| - if (mirrorSystem.libraries.values.isEmpty) {
|
| - throw new UnsupportedError('No Library Mirrors.');
|
| - }
|
| - this.libraries = mirrorSystem.libraries.values;
|
| - documentLibraries();
|
| - }
|
| + linkResolver = (name) =>
|
| + fixReference(name, _currentLibrary, _currentClass, _currentMember);
|
|
|
| - /**
|
| - * Analyzes set of libraries by getting a mirror system and triggers the
|
| - * documentation of the libraries.
|
| - */
|
| - Future<MirrorSystem> getMirrorSystem(List<String> args) {
|
| - var libraries = !parseSdk ? listLibraries(args) : listSdk();
|
| - if (libraries.isEmpty) throw new StateError('No Libraries.');
|
| - // DART_SDK should be set to the root of the SDK library.
|
| - var sdkRoot = Platform.environment['DART_SDK'];
|
| - if (sdkRoot != null) {
|
| - logger.info('Using DART_SDK to find SDK at $sdkRoot');
|
| - } else {
|
| - // If DART_SDK is not defined in the environment,
|
| - // assuming the dart executable is from the Dart SDK folder inside bin.
|
| - sdkRoot = path.dirname(path.dirname(new Options().executable));
|
| - logger.info('SDK Root: ${sdkRoot}');
|
| + getMirrorSystem(argResults.rest).then((MirrorSystem mirrorSystem) {
|
| + if (mirrorSystem.libraries.values.isEmpty) {
|
| + throw new StateError('No Library Mirrors.');
|
| }
|
| -
|
| - return getMirrorSystemHelper(libraries, sdkRoot, packageRoot: packageDir);
|
| + _documentLibraries(mirrorSystem.libraries.values);
|
| + });
|
| +}
|
| +
|
| +void _setCommandLineArguments(ArgResults argResults) {
|
| + outputToYaml = argResults['yaml'] || argResults['output-format'] == 'yaml';
|
| + outputToJson = argResults['json'] || argResults['output-format'] == 'json';
|
| + if (outputToYaml && outputToJson) {
|
| + throw new ArgumentError('Cannot have contradictory output flags.');
|
| }
|
| -
|
| - /**
|
| - * Analyzes set of libraries and provides a mirror system which can be used
|
| - * for static inspection of the source code.
|
| - */
|
| - Future<MirrorSystem> getMirrorSystemHelper(List<String> libraries,
|
| - String libraryRoot, {String packageRoot}) {
|
| - SourceFileProvider provider = new SourceFileProvider();
|
| - api.DiagnosticHandler diagnosticHandler =
|
| - new FormattingDiagnosticHandler(provider).diagnosticHandler;
|
| - Uri libraryUri = currentDirectory.resolve(appendSlash('$libraryRoot'));
|
| - Uri packageUri = null;
|
| - if (packageRoot != null) {
|
| - packageUri = currentDirectory.resolve(appendSlash('$packageRoot'));
|
| + outputToYaml = outputToYaml || !outputToJson;
|
| + includePrivate = argResults['include-private'];
|
| + parseSdk = argResults['parse-sdk'];
|
| + includeSdk = parseSdk || argResults['include-sdk'];
|
| +}
|
| +
|
| +List<String> _listLibraries(List<String> args) {
|
| + // TODO(janicejl): At the moment, only have support to have either one file,
|
| + // or one directory. This is because there can only be one package directory
|
| + // since only one docgen is created per run.
|
| + if (args.length != 1) throw new UnsupportedError(USAGE);
|
| + var libraries = new List<String>();
|
| + var type = FileSystemEntity.typeSync(args[0]);
|
| +
|
| + if (type == FileSystemEntityType.FILE) {
|
| + libraries.add(path.absolute(args[0]));
|
| + logger.info('Added to libraries: ${libraries.last}');
|
| + } else {
|
| + libraries.addAll(_listDartFromDir(args[0]));
|
| + }
|
| + logger.info('Package Directory: $packageDir');
|
| + return libraries;
|
| +}
|
| +
|
| +List<String> _listDartFromDir(String args) {
|
| + var files = listDir(args, recursive: true);
|
| + packageDir = files.firstWhere((f) =>
|
| + f.endsWith('/pubspec.yaml'), orElse: () => '');
|
| + if (packageDir != '') packageDir = path.dirname(packageDir) + '/packages';
|
| + return files.where((f) =>
|
| + f.endsWith('.dart') && !f.contains('/packages')).toList()
|
| + ..forEach((lib) => logger.info('Added to libraries: $lib'));
|
| +}
|
| +
|
| +List<String> _listSdk() {
|
| + var sdk = new List<String>();
|
| + LIBRARIES.forEach((String name, LibraryInfo info) {
|
| + if (info.documented) {
|
| + sdk.add('dart:$name');
|
| + logger.info('Add to SDK: ${sdk.last}');
|
| }
|
| - List<Uri> librariesUri = <Uri>[];
|
| - libraries.forEach((library) {
|
| - librariesUri.add(currentDirectory.resolve(library));
|
| - });
|
| - return dart2js.analyze(librariesUri, libraryUri, packageUri,
|
| - provider.readStringFromUri, diagnosticHandler,
|
| - ['--preserve-comments', '--categories=Client,Server']);
|
| + });
|
| + return sdk;
|
| +}
|
| +
|
| +/**
|
| + * Analyzes set of libraries by getting a mirror system and triggers the
|
| + * documentation of the libraries.
|
| + */
|
| +Future<MirrorSystem> getMirrorSystem(List<String> args) {
|
| + var libraries = !parseSdk ? _listLibraries(args) : _listSdk();
|
| + if (libraries.isEmpty) throw new StateError('No Libraries.');
|
| + // DART_SDK should be set to the root of the SDK library.
|
| + var sdkRoot = Platform.environment['DART_SDK'];
|
| + if (sdkRoot != null) {
|
| + logger.info('Using DART_SDK to find SDK at $sdkRoot');
|
| + } else {
|
| + // If DART_SDK is not defined in the environment,
|
| + // assuming the dart executable is from the Dart SDK folder inside bin.
|
| + sdkRoot = path.dirname(path.dirname(new Options().executable));
|
| + logger.info('SDK Root: ${sdkRoot}');
|
| }
|
|
|
| - /**
|
| - * Creates documentation for filtered libraries.
|
| - */
|
| - void documentLibraries() {
|
| - _libraries.forEach((lib) {
|
| - // Files belonging to the SDK have a uri that begins with 'dart:'.
|
| - if (includeSdk || !lib.uri.toString().startsWith('dart:')) {
|
| - var library = generateLibrary(lib);
|
| - outputLibrary(library);
|
| - }
|
| - });
|
| - // Outputs a text file with a list of files available after creating all
|
| - // the libraries. This will help the viewer know what files are available
|
| - // to read in.
|
| - _writeToFile(listDir("docs").join('\n'), 'library_list.txt');
|
| - }
|
| + return _getMirrorSystemHelper(libraries, sdkRoot, packageRoot: packageDir);
|
| +}
|
|
|
| - Library generateLibrary(dart2js.Dart2JsLibraryMirror library) {
|
| - _currentLibrary = library;
|
| - var result = new Library(library.qualifiedName, _getComment(library),
|
| - _getVariables(library.variables), _getMethods(library.functions),
|
| - _getClasses(library.classes));
|
| - logger.fine('Generated library for ${result.name}');
|
| - return result;
|
| +/**
|
| + * Analyzes set of libraries and provides a mirror system which can be used
|
| + * for static inspection of the source code.
|
| + */
|
| +Future<MirrorSystem> _getMirrorSystemHelper(List<String> libraries,
|
| + String libraryRoot, {String packageRoot}) {
|
| + SourceFileProvider provider = new SourceFileProvider();
|
| + api.DiagnosticHandler diagnosticHandler =
|
| + new FormattingDiagnosticHandler(provider).diagnosticHandler;
|
| + Uri libraryUri = currentDirectory.resolve(appendSlash('$libraryRoot'));
|
| + Uri packageUri = null;
|
| + if (packageRoot != null) {
|
| + packageUri = currentDirectory.resolve(appendSlash('$packageRoot'));
|
| }
|
| + List<Uri> librariesUri = <Uri>[];
|
| + libraries.forEach((library) {
|
| + librariesUri.add(currentDirectory.resolve(library));
|
| + });
|
| + return dart2js.analyze(librariesUri, libraryUri, packageUri,
|
| + provider.readStringFromUri, diagnosticHandler,
|
| + ['--preserve-comments', '--categories=Client,Server']);
|
| +}
|
|
|
| - void outputLibrary(Library result) {
|
| - if (outputToJson) {
|
| - _writeToFile(stringify(result.toMap()), '${result.name}.json');
|
| - }
|
| - if (outputToYaml) {
|
| - _writeToFile(getYamlString(result.toMap()), '${result.name}.yaml');
|
| +/**
|
| + * Creates documentation for filtered libraries.
|
| + */
|
| +void _documentLibraries(List<LibraryMirror> libraries) {
|
| + libraries.forEach((lib) {
|
| + // Files belonging to the SDK have a uri that begins with 'dart:'.
|
| + if (includeSdk || !lib.uri.toString().startsWith('dart:')) {
|
| + var library = generateLibrary(lib);
|
| + _outputLibrary(library);
|
| }
|
| - }
|
| + });
|
| + // Outputs a text file with a list of files available after creating all
|
| + // the libraries. This will help the viewer know what files are available
|
| + // to read in.
|
| + _writeToFile(listDir("docs").join('\n'), 'library_list.txt');
|
| +}
|
|
|
| - /// Saves list of libraries for Docgen object.
|
| - void set libraries(value){
|
| - _libraries = value;
|
| - }
|
| -
|
| - /**
|
| - * Returns any documentation comments associated with a mirror with
|
| - * simple markdown converted to html.
|
| - */
|
| - String _getComment(DeclarationMirror mirror) {
|
| - String commentText;
|
| - mirror.metadata.forEach((metadata) {
|
| - if (metadata is CommentInstanceMirror) {
|
| - CommentInstanceMirror comment = metadata;
|
| - if (comment.isDocComment) {
|
| - if (commentText == null) {
|
| - commentText = comment.trimmedText;
|
| - } else {
|
| - commentText = '$commentText ${comment.trimmedText}';
|
| - }
|
| - }
|
| - }
|
| - });
|
| - commentText = commentText == null ? '' :
|
| - markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver)
|
| - .replaceAll('\n', '');
|
| - return commentText;
|
| - }
|
| +Library generateLibrary(dart2js.Dart2JsLibraryMirror library) {
|
| + _currentLibrary = library;
|
| + var result = new Library(library.qualifiedName, _getComment(library),
|
| + _getVariables(library.variables), _getMethods(library.functions),
|
| + _getClasses(library.classes));
|
| + logger.fine('Generated library for ${result.name}');
|
| + return result;
|
| +}
|
|
|
| - /**
|
| - * Converts all [_] references in comments to <code>_</code>.
|
| - */
|
| - // TODO(tmandel): Create proper links for [_] style markdown based
|
| - // on scope once layout of viewer is finished.
|
| - markdown.Node fixReference(String name, LibraryMirror currentLibrary,
|
| - ClassMirror currentClass, MemberMirror currentMember) {
|
| - return new markdown.Element.text('code', name);
|
| - }
|
| -
|
| - /**
|
| - * Returns a map of [Variable] objects constructed from inputted mirrors.
|
| - */
|
| - Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap) {
|
| - var data = {};
|
| - mirrorMap.forEach((String mirrorName, VariableMirror mirror) {
|
| - if (includePrivate || !mirror.isPrivate) {
|
| - _currentMember = mirror;
|
| - data[mirrorName] = new Variable(mirrorName, mirror.qualifiedName,
|
| - mirror.isFinal, mirror.isStatic, mirror.type.qualifiedName,
|
| - _getComment(mirror));
|
| - }
|
| - });
|
| - return data;
|
| - }
|
| -
|
| - /**
|
| - * Returns a map of [Method] objects constructed from inputted mirrors.
|
| - */
|
| - Map<String, Method> _getMethods(Map<String, MethodMirror> mirrorMap) {
|
| - var data = {};
|
| - mirrorMap.forEach((String mirrorName, MethodMirror mirror) {
|
| - if (includePrivate || !mirror.isPrivate) {
|
| - _currentMember = mirror;
|
| - data[mirrorName] = new Method(mirrorName, mirror.qualifiedName,
|
| - mirror.isSetter, mirror.isGetter, mirror.isConstructor,
|
| - mirror.isOperator, mirror.isStatic, mirror.returnType.qualifiedName,
|
| - _getComment(mirror), _getParameters(mirror.parameters));
|
| - }
|
| - });
|
| - return data;
|
| +void _outputLibrary(Library result) {
|
| + if (outputToJson) {
|
| + _writeToFile(stringify(result.toMap()), '${result.name}.json');
|
| }
|
| -
|
| - /**
|
| - * Returns a map of [Class] objects constructed from inputted mirrors.
|
| - */
|
| - Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap) {
|
| - var data = {};
|
| - mirrorMap.forEach((String mirrorName, ClassMirror mirror) {
|
| - if (includePrivate || !mirror.isPrivate) {
|
| - _currentClass = mirror;
|
| - var superclass = (mirror.superclass != null) ?
|
| - mirror.superclass.qualifiedName : '';
|
| - var interfaces =
|
| - mirror.superinterfaces.map((interface) => interface.qualifiedName);
|
| - data[mirrorName] = new Class(mirrorName, mirror.qualifiedName,
|
| - superclass, mirror.isAbstract, mirror.isTypedef,
|
| - _getComment(mirror), interfaces.toList(),
|
| - _getVariables(mirror.variables), _getMethods(mirror.methods));
|
| - }
|
| - });
|
| - return data;
|
| + if (outputToYaml) {
|
| + _writeToFile(getYamlString(result.toMap()), '${result.name}.yaml');
|
| }
|
| -
|
| - /**
|
| - * Returns a map of [Parameter] objects constructed from inputted mirrors.
|
| - */
|
| - Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) {
|
| - var data = {};
|
| - mirrorList.forEach((ParameterMirror mirror) {
|
| +}
|
| +
|
| +/**
|
| + * Returns any documentation comments associated with a mirror with
|
| + * simple markdown converted to html.
|
| + */
|
| +String _getComment(DeclarationMirror mirror) {
|
| + String commentText;
|
| + mirror.metadata.forEach((metadata) {
|
| + if (metadata is CommentInstanceMirror) {
|
| + CommentInstanceMirror comment = metadata;
|
| + if (comment.isDocComment) {
|
| + if (commentText == null) {
|
| + commentText = comment.trimmedText;
|
| + } else {
|
| + commentText = '$commentText ${comment.trimmedText}';
|
| + }
|
| + }
|
| + }
|
| + });
|
| + commentText = commentText == null ? '' :
|
| + markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver)
|
| + .replaceAll('\n', '');
|
| + return commentText;
|
| +}
|
| +
|
| +/**
|
| + * Converts all [_] references in comments to <code>_</code>.
|
| + */
|
| +// TODO(tmandel): Create proper links for [_] style markdown based
|
| +// on scope once layout of viewer is finished.
|
| +markdown.Node fixReference(String name, LibraryMirror currentLibrary,
|
| + ClassMirror currentClass, MemberMirror currentMember) {
|
| + return new markdown.Element.text('code', name);
|
| +}
|
| +
|
| +/**
|
| + * Returns a map of [Variable] objects constructed from inputted mirrors.
|
| + */
|
| +Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap) {
|
| + var data = {};
|
| + mirrorMap.forEach((String mirrorName, VariableMirror mirror) {
|
| + if (includePrivate || !mirror.isPrivate) {
|
| + _currentMember = mirror;
|
| + data[mirrorName] = new Variable(mirrorName, mirror.qualifiedName,
|
| + mirror.isFinal, mirror.isStatic, mirror.type.qualifiedName,
|
| + _getComment(mirror));
|
| + }
|
| + });
|
| + return data;
|
| +}
|
| +
|
| +/**
|
| + * Returns a map of [Method] objects constructed from inputted mirrors.
|
| + */
|
| +Map<String, Method> _getMethods(Map<String, MethodMirror> mirrorMap) {
|
| + var data = {};
|
| + mirrorMap.forEach((String mirrorName, MethodMirror mirror) {
|
| + if (includePrivate || !mirror.isPrivate) {
|
| _currentMember = mirror;
|
| - data[mirror.simpleName] = new Parameter(mirror.simpleName,
|
| - mirror.qualifiedName, mirror.isOptional, mirror.isNamed,
|
| - mirror.hasDefaultValue, mirror.type.qualifiedName,
|
| - mirror.defaultValue);
|
| - });
|
| - return data;
|
| + data[mirrorName] = new Method(mirrorName, mirror.qualifiedName,
|
| + mirror.isSetter, mirror.isGetter, mirror.isConstructor,
|
| + mirror.isOperator, mirror.isStatic, mirror.returnType.qualifiedName,
|
| + _getComment(mirror), _getParameters(mirror.parameters));
|
| + }
|
| + });
|
| + return data;
|
| +}
|
| +
|
| +/**
|
| + * Returns a map of [Class] objects constructed from inputted mirrors.
|
| + */
|
| +Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap) {
|
| + var data = {};
|
| + mirrorMap.forEach((String mirrorName, ClassMirror mirror) {
|
| + if (includePrivate || !mirror.isPrivate) {
|
| + _currentClass = mirror;
|
| + var superclass = (mirror.superclass != null) ?
|
| + mirror.superclass.qualifiedName : '';
|
| + var interfaces =
|
| + mirror.superinterfaces.map((interface) => interface.qualifiedName);
|
| + data[mirrorName] = new Class(mirrorName, mirror.qualifiedName,
|
| + superclass, mirror.isAbstract, mirror.isTypedef,
|
| + _getComment(mirror), interfaces.toList(),
|
| + _getVariables(mirror.variables), _getMethods(mirror.methods));
|
| + }
|
| + });
|
| + return data;
|
| +}
|
| +
|
| +/**
|
| + * Returns a map of [Parameter] objects constructed from inputted mirrors.
|
| + */
|
| +Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) {
|
| + var data = {};
|
| + mirrorList.forEach((ParameterMirror mirror) {
|
| + _currentMember = mirror;
|
| + data[mirror.simpleName] = new Parameter(mirror.simpleName,
|
| + mirror.qualifiedName, mirror.isOptional, mirror.isNamed,
|
| + mirror.hasDefaultValue, mirror.type.qualifiedName,
|
| + mirror.defaultValue);
|
| + });
|
| + return data;
|
| +}
|
| +
|
| +/**
|
| + * Writes text to a file in the 'docs' directory.
|
| + */
|
| +void _writeToFile(String text, String filename) {
|
| + Directory dir = new Directory('docs');
|
| + if (!dir.existsSync()) {
|
| + dir.createSync();
|
| }
|
| + File file = new File('docs/$filename');
|
| + if (!file.existsSync()) {
|
| + file.createSync();
|
| + }
|
| + file.openSync();
|
| + file.writeAsString(text);
|
| }
|
|
|
| /**
|
| @@ -399,8 +398,9 @@ class Class {
|
| bool isAbstract;
|
| bool isTypedef;
|
|
|
| - Class(this.name, this.qualifiedName, this.superclass, this.isAbstract, this.isTypedef,
|
| - this.comment, this.interfaces, this.variables, this.methods);
|
| + Class(this.name, this.qualifiedName, this.superclass, this.isAbstract,
|
| + this.isTypedef, this.comment, this.interfaces, this.variables,
|
| + this.methods);
|
|
|
| /// Generates a map describing the [Class] object.
|
| Map toMap() {
|
| @@ -500,8 +500,8 @@ class Parameter {
|
| String type;
|
| String defaultValue;
|
|
|
| - Parameter(this.name, this.qualifiedName, this.isOptional, this.isNamed, this.hasDefaultValue,
|
| - this.type, this.defaultValue);
|
| + Parameter(this.name, this.qualifiedName, this.isOptional, this.isNamed,
|
| + this.hasDefaultValue, this.type, this.defaultValue);
|
|
|
| /// Generates a map describing the [Parameter] object.
|
| Map toMap() {
|
| @@ -516,19 +516,3 @@ class Parameter {
|
| return parameterMap;
|
| }
|
| }
|
| -
|
| -/**
|
| - * Writes text to a file in the 'docs' directory.
|
| - */
|
| -void _writeToFile(String text, String filename) {
|
| - Directory dir = new Directory('docs');
|
| - if (!dir.existsSync()) {
|
| - dir.createSync();
|
| - }
|
| - File file = new File('docs/$filename');
|
| - if (!file.existsSync()) {
|
| - file.createSync();
|
| - }
|
| - file.openSync();
|
| - file.writeAsString(text);
|
| -}
|
|
|