2013-05-26 19:25:24 -03:00
#!/usr/bin/env python
import re
from param import *
from emit import Emit
2013-05-27 10:17:47 -03:00
import cgi
2013-05-26 19:25:24 -03:00
# Emit docs in a form acceptable to the APM wordpress docs site
class HtmlEmit ( Emit ) :
def __init__ ( self ) :
html_fname = ' Parameters.html '
self . f = open ( html_fname , mode = ' w ' )
self . preamble = ''' <!-- Dynamically generated list of documented parameters
This page was generated using Tools / autotest / param_metadata / param_parse . py
DO NOT EDIT
- - >
2013-05-27 21:11:56 -03:00
2013-05-29 23:19:24 -03:00
< p style = " text-align: right " > < a title = " Table of Contents " href = " /wiki/table-of-contents/ " > < span style = " font-size: medium " > < strong > Reference Manual Table of Contents < / strong > < / span > < / a > < / p >
2013-05-29 23:36:05 -03:00
< h3 style = " text-align: center " > Complete Parameter List < / h3 >
< hr / >
2013-05-29 23:19:24 -03:00
2013-05-27 21:11:56 -03:00
< p > This is a complete list of the parameters which can be set via the MAVLink protocol in the EEPROM of your APM to control vehicle behaviour . This list is automatically generated from the latest ardupilot source code , and so may contain parameters which are not yet in the stable released versions of the code . < / p >
2013-05-29 23:36:05 -03:00
< ! - - add auto - generated table of contents with " Table of Contents Plus " plugin - - >
[ toc exclude = " Complete Parameter List " ]
2013-05-26 19:25:24 -03:00
'''
self . t = ' '
def escape ( self , s ) :
s = s . replace ( ' ' , ' - ' )
s = s . replace ( ' : ' , ' - ' )
s = s . replace ( ' ( ' , ' ' )
s = s . replace ( ' ) ' , ' ' )
return s
def close ( self ) :
self . f . write ( self . preamble )
self . f . write ( self . t )
self . f . close ( )
def start_libraries ( self ) :
2013-05-27 21:11:56 -03:00
self . t + = ' \n \n <h1>Library Parameters</h1> \n \n '
2013-05-26 19:25:24 -03:00
def emit ( self , g , f ) :
tag = ' %s Parameters ' % g . name
t = ' \n \n <h1> %s </h1> \n ' % tag
for param in g . params :
if not hasattr ( param , ' DisplayName ' ) or not hasattr ( param , ' Description ' ) :
continue
2013-05-27 21:11:56 -03:00
d = param . __dict__
2013-05-26 19:25:24 -03:00
tag = ' %s ( %s ) ' % ( param . DisplayName , param . name )
t + = ' \n \n <h2> %s </h2> ' % tag
2013-05-27 21:11:56 -03:00
if d . get ( ' User ' , None ) == ' Advanced ' :
t + = ' <em>Note: This parameter is for advanced users</em><br> '
2013-05-27 10:17:47 -03:00
t + = " \n \n <p> %s </p> \n " % cgi . escape ( param . Description )
2013-05-26 19:25:24 -03:00
t + = " <ul> \n "
for field in param . __dict__ . keys ( ) :
if field not in [ ' name ' , ' DisplayName ' , ' Description ' , ' User ' ] and field in known_param_fields :
if field == ' Values ' and Emit . prog_values_field . match ( param . __dict__ [ field ] ) :
values = ( param . __dict__ [ field ] ) . split ( ' , ' )
t + = " <table><th>Value</th><th>Meaning</th> \n "
for value in values :
v = value . split ( ' : ' )
t + = " <tr><td> %s </td><td> %s </td></tr> \n " % ( v [ 0 ] , v [ 1 ] )
t + = " </table> \n "
else :
2013-05-27 10:17:47 -03:00
t + = " <li> %s : %s </li> \n " % ( field , cgi . escape ( param . __dict__ [ field ] ) )
2013-05-26 19:25:24 -03:00
t + = " </ul> \n "
self . t + = t