avatarFred Grott

Summary

This website article provides a tutorial on how to generate professional documentation for Flutter apps, plugins, or packages using the DartDoc tool and configuring it with a dartdoc_options.yaml file, while also setting up a local http server for search functionality.

Abstract

The article titled "Cool Flutter Docs" on the undefined website offers a comprehensive guide for developers aiming to create polished documentation for their Flutter projects. It begins by emphasizing the importance of quality documentation for professional code presentation. The author outlines the pre-requisites, which include installing the DartDoc tool and the dhttpd server. The installation is done through the command line interface. The article then delves into configuring DartDoc by using a dartdoc_options.yaml file, drawing inspiration from the Flutter SDK's own configuration on GitHub. The author provides examples of custom configurations and explains how to generate the documentation, view it, and ensure search functionality works correctly. The article also touches on the importance of a well-crafted README file and points readers to additional resources and the author's personal social platforms.

Opinions

  • The author believes that having well-generated documentation is a sign of developer professionalism and polish.
  • They recommend examining the internals of the SDK source code to gain insights and improve one's own documentation practices.
  • The author suggests that the DartDoc tool is preferable to other documentation tools like doxygen due to its ease of use, especially when managing multiple projects.
  • A "SIDE NOTE" implies that the structure and content of a project's README file are crucial for a professional-looking index page in the API documentation.
  • The author expresses a personal commitment to writing about Flutter development, design, and life, and invites readers to follow their work and progress on various social media platforms.
  • There is an opinion that adhering to brand and usage guidelines of various trademarks in the tech industry is important.

Cool Flutter Docs

A sign of developer polish and professionalism is being able to have some cool docs generated for your flutter app, plugin, or package. Let me show you how to do that in an easy way.

Pre-Requirements

This is somewhat realy easy as there are only two items to install. First, let’s install the dartdoc tool via your command line:

flutter pub global activate dartdoc

Now, let’s also install an dart http server so that the doc search will work as than you will not get search not accessible errors due to the browser blocking cross scripting. Type this into your terminal:

flutter pub global activate dhttpd

Now, I can configure the dartdoc tool.

Configuring DartDoc

The DartDoc tool will look for a dartdoc_options.yaml file in the root project folder. Now I will show you some of my developer tricks.

When ever you begin learning a new computer language or framework start looking at the internals of the sdk. In Flutter’s case the sdk source is on github. And, if you look you will notice a dartdoc_options.yaml file in it; this one:

I am not going to use some parts of it as I have no processing tools to hook into the doc generation process. But I will use the second part which defines the errors:

I added paths to my favicon and an alternative header to use in generating the api docs.

Generating The Docs

Now to generate the docs type this into your terminal:

dartdoc

gives this output:

And to view it with search working type this into your terminal:

dhttpd --path doc/api

And your api site is viewable at:

http://localhost:8080

It looks like this:

SIDE NOTE: The DartDoc tool will pick up and inject the content of your project’s root readme as content of the index page at the root of the api folder. I have a nice readme site that describes how to properly write a project readme at:

Take some time to emulate it so that you can have polished project readme’s.

And so you can see what happens when the dart httpd server is not running, here is the main dart index page:

Conclusion

Documenting your mobile app api looks polished and makes it easy to see how it works later when you are in the process of maintaining 5 or more mobile apps that you have published. And it’s easier to use this dartdoc tool than some other tools like doxygen.

Resources

Specific to the article: [email protected] https://pub.dev/packages/dartdoc dartdoc_options file@githubFlutterRepo https://github.com/flutter/flutter/blob/master/dartdoc_options.yaml

General Flutter and Dart resources:

Flutter Community Resources https://flutter.dev/community Flutter SDK https://flutter.dev/docs/get-started/install Android Studio IDE https://developer.android.com/studio MS’s Visual Studio Code https://code.visualstudio.com/ Flutter Docs https://flutter.dev/docs Dart Docs https://dart.dev/guides Google Firebase Mobile Device TestLab https://firebase.google.com/docs/test-lab

Trademark Notice

Google LLC owns the following trademarks; Dart, Flutter, Android, Roboto, Noto. Apple Inc owns the trademarks iOS, MacOSX, Swift, and ObjectiveC. Apple Inc owns trademarks to their fonts of SF Pro, Sf Compact, SF mono, and New York. JetBeans Inc owns the trademarks to JetBeans, IntelliJ, and Kotlin. Oracle Inc owns the Java trademark. Microsoft Inc owns the trademarks to MS Windows OS and Powershell. Gradle is a trademark of Gradle Inc. The Git Project owns the trademark to Git. Linux Foundation owns the trademark to Linux. SmartPhone OME’s own trademarks to their mobile phone product names. To the best of my ability I follow the brand and usage guidelines with the above mentioned trademarks.

About Fred Grott

I’m the crazy SOB who as a former android mobile developer is starting to write about flutter mobile app development, design, and life(see Eff COVID and GOP https://fredgrott.medium.com/eff-covid-and-the-gop-e912db0548b8). Will I reach the pivotal One Million Medium monthly viewers mark? Sit-back and watch it happen. Find me on these social platforms:

https://twitter.com/fredgrott

Flutter
DevOps
iOS
Android
Development
Recommended from ReadMedium