Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
root = true

[*]
indent_style = space
indent_size = tab
tab_width = 4
insert_final_newline = true

[*.xml]
tab_width = 2
trim_trailing_whitespace = true

[*.php]
insert_final_newline = false

[*.css]
insert_final_newline = false

[*.py]
# Otherwise Python language server complains
trim_trailing_whitespace = true

[*.xsl]
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = true
tab_width = 2

[*.json]
tab_width = 2
trim_trailing_whitespace = true

[*.{yml,yaml}]
tab_width = 2

[*.{c,cpp,cc,h,hpp}]
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "pymavlink"]
path = pymavlink
url = https://github.com/ArduPilot/pymavlink.git
url = https://github.com/ArduPilot/pymavlink.git
6 changes: 3 additions & 3 deletions component_information/parameter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"description": "Parameter Name.",
"type": "string",
"pattern": "^[\\.\\-a-zA-Z0-9_\\{\\}]{1,16}$",
"comment": "FOO{n}_BAR for name will match actual name of FOO1_BAR, FOO3_BAR and so forth."
"comment": "FOO{n}_BAR for name will match actual name of FOO1_BAR, FOO3_BAR and so forth."
},
"type": {
"description": "Parameter type.",
Expand All @@ -31,13 +31,13 @@
"description": "Short user facing description/name for parameter. Used in UI intead of internal parameter name.",
"type": "string",
"default": "",
"comment": "{n} index tagging will be replaced by name index. Example: 'FOO3_BAR': 'Description for foo element {n}' will turn into 'Description for foo element 1'."
"comment": "{n} index tagging will be replaced by name index. Example: 'FOO3_BAR': 'Description for foo element {n}' will turn into 'Description for foo element 1'."
},
"longDesc": {
"description": "Long user facing documentation of how the parameters works.",
"type": "string",
"default": "",
"comment": "{n} index tagging will be replaced by name index. Example: 'FOO3_BAR': 'Description for foo element {n}' will turn into 'Description for foo element 1'."
"comment": "{n} index tagging will be replaced by name index. Example: 'FOO3_BAR': 'Description for foo element {n}' will turn into 'Description for foo element 1'."
},
"units": {
"description": "Units for parameter value.",
Expand Down
42 changes: 21 additions & 21 deletions doc/mavlink_gitbook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/python

"""
This script generates markdown files for all the MAVLink message definition XML at:
This script generates markdown files for all the MAVLink message definition XML at:
https://github.com/mavlink/mavlink/tree/master/message_definitions/v1.0

The files can be imported into a gitbook to display the messages as HTML

The script runs on both Python2 and Python 3. The following libraries must be imported: lxml, requests, bs4.
Expand Down Expand Up @@ -36,7 +36,7 @@
xsl_file = content_file.read()
xslt = ET.fromstring(xsl_file)

#initialise text for index file.
#initialise text for index file.
index_text="""<!-- THIS FILE IS AUTO-GENERATED (DO NOT UPDATE GITBOOK): https://github.com/mavlink/mavlink/blob/master/doc/mavlink_gitbook.py -->
# XML Definition Files & Dialects

Expand All @@ -59,7 +59,7 @@

> **Note** We are still working towards moving the truly standard entities from **common.xml** to **standard.xml**
Currently you should include [common.xml](../messages/common.md)

In addition:
- [development.xml](development.md) - XML definitions that are _proposed_ for inclusion in the standard definitions.
These are work in progress.
Expand Down Expand Up @@ -89,7 +89,7 @@
"""

#Fix up the BeautifulSoup output so to fix build-link errors in the generated gitbook.
## BS puts each tag/content in its own line. Gitbook generates anchors using the spaces/newlines.
## BS puts each tag/content in its own line. Gitbook generates anchors using the spaces/newlines.
## This puts displayed text content immediately within tags so that anchors/links generate properly
def fix_content_in_tags(input_html):
#print("fix_content_in_tags was called")
Expand All @@ -99,7 +99,7 @@ def remove_space_between_content_tags(matchobj):

input_html=re.sub(r'\>(\s+?\w+?.*?)\<', remove_space_between_content_tags, input_html,flags=re.DOTALL)
return input_html

def fix_external_dialect_link(input_html):
#print("fix_external_dialect_link was called")
def fixupexternaldialecturls(matchobj):
Expand All @@ -123,9 +123,9 @@ def strip_text_before_string(original_text,strip_text):
index=original_text.find(strip_text)
stripped_string=original_text
if index !=-1 :
stripped_string = stripped_string[index:]
stripped_string = stripped_string[index:]
return stripped_string

def fix_add_implicit_links_items(input_html):
# Makes screaming snake case into anchors. Special fix for MAV_CMD.
#print("fix_add_implicit_link was called")
Expand All @@ -141,8 +141,8 @@ def make_text_to_link(matchobj):

input_html=re.sub(r'([\`\(\s,]|^)([A-Z]{2,}(?:_[A-Z0-9]+)+)([\`\)\s\.,:]|$)', make_text_to_link, input_html,flags=re.DOTALL)
return input_html


def inject_top_level_docs(input_html,filename):
#Inject top level heading and other details.
print('FILENAME (prefix): %s' % filename)
Expand Down Expand Up @@ -204,7 +204,7 @@ def inject_top_level_docs(input_html,filename):

> **Warning** New dialect files in the official repository must be added to **all.xml** and restrict themselves to using ids in their own allocated range.
A few older dialects are not included because these operate in completely closed networks or because they are only used for tests.

This topic is a human-readable form of the XML definition file: [all.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/all.xml).
"""
else:
Expand Down Expand Up @@ -238,12 +238,12 @@ def inject_top_level_docs(input_html,filename):

{% include "_html/minimal.html" %}"""


#print(input_html)
return input_html

dialect_files = set()
all_files = set()
all_files = set()

for subdir, dirs, files in os.walk(xml_message_definitions_dir_name):
#Generate html for all the XML files
Expand All @@ -265,7 +265,7 @@ def inject_top_level_docs(input_html,filename):
#Strip out text before <html> tag in XSLT output
prettyHTML=strip_text_before_string(prettyHTML,'<html>')
prettyHTML = fix_content_in_tags(prettyHTML)

#Replace invalid file extensions (workaround for xslt)
prettyHTML = fix_include_file_extension(prettyHTML)

Expand All @@ -274,11 +274,11 @@ def inject_top_level_docs(input_html,filename):

#Fix up links to external dialects to not be links
prettyHTML = fix_external_dialect_link(prettyHTML)

#Fix up plain text mav symbols to be internal links
prettyHTML = fix_add_implicit_links_items(prettyHTML)
prettyHTML = fix_add_implicit_links_items(prettyHTML)


#Write output html file
output_file_name_html = file.rsplit('.',1)[0]+".html"

Expand Down Expand Up @@ -309,12 +309,12 @@ def inject_top_level_docs(input_html,filename):
with open(output_file_name_md_withdir, 'w') as out:
out.write(markdown_text)


for the_file in sorted(dialect_files):
index_text+='\n* [%s.xml](%s.md)' % (the_file,the_file)
index_text+='\n\n'
index_text+=index_text_trailer

#Write the index
with open(index_file_name, 'w') as content_file:
content_file.write(index_text)
Expand Down
2 changes: 1 addition & 1 deletion doc/mavlink_to_html_table.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<p>
The <a href="https://mavlink.io/en/messages/common.html">Official MAVLink message documentation</a> contains additional information, including field units and enum values.
</p>

<h2>MAVLink Protocol Version</h2>
<p>The current MAVLink version is 2.<xsl:value-of select="." />. The minor version numbers (after the dot) range from 1-255. </p>
</xsl:template>
Expand Down
24 changes: 12 additions & 12 deletions doc/mavlink_to_html_table_gitbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<xsl:if test='*/@units'>
<th>Units</th>
</xsl:if>

<xsl:if test='*/@enum'>
<th>Values</th>
</xsl:if>
Expand All @@ -56,7 +56,7 @@
</tr>
</thead>
<tbody>
<xsl:apply-templates select="field" />
<xsl:apply-templates select="field" />
</tbody>
</table>
</xsl:template>
Expand All @@ -72,20 +72,20 @@
<td><xsl:value-of select="@name" /></td> <!-- mavlink_name -->
</xsl:otherwise>
</xsl:choose>

<td><xsl:value-of select="@type" /></td> <!-- mavlink_type -->

<xsl:if test='../*/@units'>
<td><xsl:value-of select="@units" /></td> <!-- mavlink_units -->
</xsl:if>

<xsl:if test='../*/@enum'>
<td><xsl:if test='@enum'>
<a><xsl:attribute name="href">#<xsl:value-of select="@enum" /></xsl:attribute><xsl:value-of select="@enum" /></a>
</xsl:if>
</td> <!-- mavlink_value -->
</xsl:if>

<td><xsl:value-of select="." /></td> <!-- mavlink_comment -->
</tr>
</xsl:template>
Expand All @@ -104,7 +104,7 @@
<h3> <!-- mavlink_enum_name -->
<xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:value-of select="@name" /></h3>
<xsl:apply-templates select="deprecated" />
<xsl:apply-templates select="deprecated" />
<p><a href="#enums">[Enum]</a><xsl:value-of select="description" /></p> <!-- description -->
<table class="sortable">
<thead>
Expand Down Expand Up @@ -151,7 +151,7 @@
</tr>
</thead>
<tbody>
<xsl:apply-templates select="param" mode="params" />
<xsl:apply-templates select="param" mode="params" />
</tbody>
</table>

Expand All @@ -162,7 +162,7 @@
<tr id="{@name}"> <!-- mavlink_field -->
<td><xsl:value-of select="@value" /></td> <!-- mavlink_type -->
<td>
<a><xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name" /></a>
<a><xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name" /></a>
<xsl:apply-templates select="deprecated" />
<xsl:apply-templates select="wip" />
</td> <!-- mavlink_name -->
Expand All @@ -185,7 +185,7 @@

<xsl:template match="//param" mode="params">
<tr>
<td><xsl:value-of select="@index" />
<td><xsl:value-of select="@index" />
<xsl:if test='@label'>: <xsl:value-of select="@label" /></xsl:if>
</td> <!-- mission_param -->

Expand All @@ -211,11 +211,11 @@
</xsl:choose>
</td>
</xsl:if>

<xsl:if test='../*/@units'>
<td><xsl:value-of select="@units" /></td> <!-- mavlink_units -->
</xsl:if>

</tr>
</xsl:template>

Expand Down
Loading