17 May 2020

Document the libraries you use in your platformio project

By Bolukan

PlatformIO IDE delivers a powerfull environment for your Arduino code projects and organises thousands of libraries including a project dependency manager. By adding the identifier into the platformio.ini file of your project, PlatformIO will download the library and its dependencies. To document the libraries used, I insert comment lines in platformio.ini.

Platform IO

To keep the comments correct and standardised I created an text file with all the comment lines on libraries. It became a job to add lines for new libraries and also slowed down adding libraries into new projects. Time to automate this job.

Former list to documentation libraries

First I looked into scraping PlatformIO library pages, but in a second attempt I discovered they offer a nice API. The API endpoint https://api.platformio.org/lib/info/<id> returns the needed info. I put the logic to retrieve and format the data in a PHP-page, which is available as gist on my github: platformio.php.

How to use the code

Call the script as follows: platformio.php?id=<id>[,<id2>]. As you may notice the script can process multiple libraries in one call. Make sure not to overload your and their server! The returned lines are formatted with up to 80 characters and information will be split into multiple lines if needed. I also added extra information to document which version was used when the project was created.

New layout of library documentation
Layout of library documenation using PHP-script

Now I can add new libraries including the documentation very quickly. And it is no longer needed to maintain a text file with the standardized documentation.