A tool for maintaining Dart comments.

Overview

Version CI

A tool for maintaining Dart comments (daco).

This package is in an early stage of development. Please file an issue if you find a bug or start a discussion if you have a question.

Getting started

  1. Make sure you have a recent version of NodeJS (>=14) installed and on the path. daco uses prettier to format Markdown.

  2. Install daco globally:

    dart pub global activate daco
  3. Format the Dart files within the current directory:

    daco format .

Formatting

daco formats documentation comments in Dart files.

prettier is used to format comments as Markdown. This means that the conventions of prettier are applied, such as using ** to bold text instead of __. A nice feature of prettier is that Markdown tables are pretty-printed.

Prose is reprinted to optimally fit within the specified line length (defaults to 80):

- /// The quick brown fox     jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
+ /// The quick brown fox jumps over the lazy dog. The quick brown fox jumps over
+ /// the lazy dog.
  const foo = 'bar';

This is useful when writing and updating documentation comments and an edit pushes some text beyond the preferred line length.

Embedded Dart code

Fenced code blocks that are tagged with dart are formatted as Dart code.

  /// A top level constant.
  ///
  /// ```dart
- /// const fooList = [foo,];
+ /// const fooList = [
+ ///   foo,
+ /// ];
  /// ```
  const foo = 'bar';

The Dart code is parsed and if it contains syntactic errors they are reported with correct line and column numbers. This provides a basic check for this code, ensuring it is at least syntactically correct.

If the code does not represent a valid Dart file, formatting of it can be disabled by tagging it with no_format:

/// A top level constant.
///
/// ```dart no_format
/// print(foo)
/// ```
const foo = 'bar';

Formatting of Dart code and documentation comments is recursive. That means comments in fenced code blocks containing Dart code are formatted too.

Dartdoc tags

Dartdoc supports tags for features such as templates. Dartdoc tags should be separated from other content with an empty line, since prettier does not recognize them as special and formats them as simple text:

/// A top level constant.
///
/// {@template foo}
///
/// The template content.
///
/// {@endtemplate}
const foo = 'bar';

When formatting a preexisting codebase special attention should be paid to the location of dartdoc tags after formatting.

TODO

  • Support standalone statements in embedded Dart code
  • Support formatting of end of line comments
  • Support disabling formatting for a comment

Ideas

  • Integrate formatting with IDEs
  • Analyze comments
    • Spelling
    • Punctuation
  • Format Dart code in Markdown files
  • Analyze Dart code embedded in Markdown
  • Test Dart code embedded in Markdown
  • Embedded templates in Markdown
    • Template is commented out
    • Below template, output of template is injected/updated

Gabriel TerwestenGitHub @blaugoldTwitter @GTerwestenMedium @gabriel.terwesten

You might also like...

The one and only Docker Tool you will ever need again

# container_tool A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you

Nov 17, 2021

A simple, private tool to help pick a baby name.

A simple, private tool to help pick a baby name.

Nom de Bébé A simple, private tool to help pick a baby name. https://nomdebebe.app/ Motivation I need to choose a name. There's lots of tools and apps

Nov 23, 2022

A tool for digitizing medical history, prescriptions, and reports.

A tool for digitizing medical history, prescriptions, and reports.

Shealth A tool for digitising medical history, prescriptions and report Landing page Login page Home page Registeration page Installation To render re

Dec 26, 2022

Integrate Flutter with the Facebook Stetho tool for Android

Integrate Flutter with the Facebook Stetho tool for Android

flutter_stetho A plugin that connects Flutter to the Chrome Dev Tools on Android devices via the Stetho Android Library. Network Inspector The main fe

Nov 20, 2022

🚀 A simple & beautiful mobile tool for pictures uploading built by flutter

🚀 A simple & beautiful mobile tool for pictures uploading built by flutter

Flutter-PicGo 图片上传+管理新体验 应用概述 Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的手机版工具 Flutter-PicGo 本体支持如下图床: GitHub [v1.0+] SM.MS [v1.1+] Gitee [v1.2+] 七牛云 [v1.3+]

Jan 5, 2023

This is a tool for adding define macro definition to programming languages.

This is a tool for adding define macro definition to programming languages. It is used to distinguish different versions and platforms. The implementation principle is to annotate unnecessary code by using define macros. This tool is theoretically applicable to any programming language.

Dec 7, 2022

Software analytics tool that helps developers analyse and improve software quality.

Software analytics tool that helps developers analyse and improve software quality.

Dart Code Metrics Note: you can find the full documentation on the website Configuration | Rules | Metrics | Anti-patterns Dart Code Metrics is a stat

Dec 26, 2022

Custom flutter testing CLI tool for individual test runs and group testing

fluttertest Custom flutter testing CLI tool for inidividual test runs or group testing Overview Flutter is a great framework which has helps developer

Nov 6, 2022

A collection of templates to make new Flutter components using the Mason build tool.

Mason Flutter Templates A collection of templates to make new Flutter components using the Mason build tool. Setup in Project To use these templates i

Jun 21, 2022
Comments
  • Highlighting is flaky

    Highlighting is flaky

    Dart code examples are only highlighted sometimes, and it's not clear what the circumstances are under which it works.

    The reason might be that IDEs requests semantic tokens before the analyzer plugin is able to provide highlighting data.

    bug 
    opened by blaugold 0
  • Support running code examples

    Support running code examples

    Types of code examples:

    • App
      • Long running.
      • For example Flutter app or HTTP server.
      • Has a main function for entry point.
      • Cannot be run as part of tests.
    • Script
      • Does some work and exits.
      • Might use asserts and expect.
      • Has a main function for entry point.
        • Might have a WidgetTester parameter if it is meant to be executed as a widget test.
      • By default, the code in the main function is executed in a test case.
        • If the main function contains test definitions, it should be possible to disable this and run it directly.

    Dart can run on a number of platforms. How do we decide on which platform to run a code example?

    opened by blaugold 0
This is tool to create 3D Models which can be used in Flutter Applications. Tool is developed completely using Flutter.

three_d_model_tool A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Shubham Yeole 2 Nov 8, 2022
Tool made in Dart that allows you to dynamically generate JSON files from data models written in Dart.

Dart JSON Generator Versión v1.1.1 Dart JSON Generator es una herramienta que permite generar archivos JSON a partir de mapas como modelos de datos en

Joinner Medina 7 Nov 23, 2022
This is an opinionated code-generation tool from GraphQL to Dart/Flutter.

GraphQL Codegen This is an opinionated code-generation tool from GraphQL to Dart/Flutter. It'll allow you to generate Dart serializers and client help

United Traders 1 Dec 29, 2021
A package script for allowing coverage test tool to see all Dart files

full_coverage Coverage tools like codecov only see the files that were actually triggered by tests. This means that a coverage of 100% can easily be a

Flutterando 2 Mar 18, 2022
Alternative i18n tool for Dart and Flutter.

Simple internationalization (i18n) package for Dart and Flutter. Supports: AngularDart Flutter hot reload deferred loading of translations social dist

fnx.io 32 Dec 10, 2022
This is a simple Gantt chart generator written as Dart command line tool.

Gantt Chart Generator This is a simple Gantt chart generator written as Dart command line tool. Currently the tool generates an HTML/CSS Gantt chart.

John Lyon-Smith 1 Apr 26, 2022
A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances.

h5ai scraper A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances. Usage This tool requires the Dart SDK. It can be

null 1 Jan 4, 2023
Dart JS interop for Mermaid - The Javascript tool that makes use of a markdown based syntax to render customizable diagrams, charts and visualizations.

Mermaid (Dart) Dart JS interop for Mermaid - Javascript library that makes use of a markdown based syntax to render customizable diagrams, charts and

Tim Maffett 3 Dec 12, 2022
Protofu is a Dart Command Line tool for generating your protobufs and included dependencies in one command.

ProtoFu - let me compile that for you ProtoFu exists to make working with protobufs easier. Gone are the days of downloading protoc and the dart proto

John McDole 5 Oct 27, 2022
Simple tool to open WhatsApp chat without saving the number, developed using Google's Flutter Framework. for Android/ IOS/ Desktop/ Web

OpenWp Simple tool to open WhatsApp chat without saving the number Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About

Swarup Bhanja Chowdhury 15 Nov 1, 2022