2017-05-02 11:05:15 -03:00
|
|
|
from xml.sax.saxutils import escape
|
|
|
|
import codecs
|
|
|
|
import os
|
|
|
|
|
|
|
|
class MarkdownTablesOutput():
|
|
|
|
def __init__(self, module_groups):
|
|
|
|
|
2017-05-05 06:50:57 -03:00
|
|
|
self._outputs = {}
|
|
|
|
|
2017-05-02 11:05:15 -03:00
|
|
|
result = """
|
|
|
|
# Modules & Commands Reference
|
2017-05-05 06:50:57 -03:00
|
|
|
The following pages document the PX4 modules, drivers and commands. They
|
|
|
|
describe the provided functionality, high-level implementation overview and how
|
|
|
|
to use the command-line interface.
|
2017-05-02 11:05:15 -03:00
|
|
|
|
2017-05-05 06:50:57 -03:00
|
|
|
> **Note** **This is auto-generated from the source code** and contains the
|
2017-05-02 11:05:15 -03:00
|
|
|
> most recent modules documentation.
|
|
|
|
|
2017-05-05 06:50:57 -03:00
|
|
|
It is not a complete list and NuttX provides some additional commands
|
2017-05-02 11:05:15 -03:00
|
|
|
as well (such as `free`). Use `help` on the console to get a list of all
|
|
|
|
available commands, and in most cases `command help` will print the usage.
|
|
|
|
|
|
|
|
Since this is generated from source, errors must be reported/fixed
|
|
|
|
in the [Firmware](https://github.com/PX4/Firmware) repository.
|
|
|
|
|
2017-05-05 06:50:57 -03:00
|
|
|
## Categories
|
2017-05-02 11:05:15 -03:00
|
|
|
"""
|
2017-05-05 06:50:57 -03:00
|
|
|
for category in sorted(module_groups):
|
|
|
|
result += "- [%s](modules_%s.md)\n" % (category.capitalize(), category)
|
|
|
|
|
|
|
|
self._outputs['main'] = result
|
|
|
|
|
2017-05-02 11:05:15 -03:00
|
|
|
|
|
|
|
for category in sorted(module_groups):
|
2017-05-05 06:50:57 -03:00
|
|
|
result = "# Modules Reference: %s\n" % category.capitalize()
|
2017-05-02 11:05:15 -03:00
|
|
|
module_list = module_groups[category]
|
|
|
|
for module in module_list:
|
|
|
|
result += "## %s\n" % module.name()
|
|
|
|
result += "Source: [%s](https://github.com/PX4/Firmware/tree/master/src/%s)\n\n" % (module.scope(), module.scope())
|
|
|
|
doc = module.documentation()
|
|
|
|
if len(doc) > 0:
|
|
|
|
result += "%s\n" % doc
|
|
|
|
usage_string = module.usage_string()
|
|
|
|
if len(usage_string) > 0:
|
|
|
|
result += "### Usage\n```\n%s\n```\n" % usage_string
|
|
|
|
|
2017-05-05 06:50:57 -03:00
|
|
|
self._outputs[category] = result
|
2017-05-02 11:05:15 -03:00
|
|
|
|
|
|
|
def Save(self, dirname):
|
2017-05-05 06:50:57 -03:00
|
|
|
for output_name in self._outputs:
|
|
|
|
output = self._outputs[output_name]
|
|
|
|
with codecs.open(os.path.join(dirname, 'modules_'+output_name+'.md'), 'w', 'utf-8') as f:
|
|
|
|
f.write(output)
|