Skip to content

Commit 6ac37cd

Browse files
authored
Docs generation improvements (mavlink#2139)
* Dialects more clearly not necessarily accurate to fork * Common.xml includes all entities
1 parent 139e1b0 commit 6ac37cd

File tree

1 file changed

+69
-23
lines changed

1 file changed

+69
-23
lines changed

doc/mavlink_xml_to_markdown.py

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,6 @@ def get_top_level_docs(self, filename):
297297
The original definitions are defined in [standard.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/standard.xml).
298298
"""
299299

300-
elif filename == 'ardupilotmega':
301-
insert_text += """
302-
# Dialect: ArduPilotMega
303-
304-
These messages define the ArduPilot specific message set, which is custom to [http://ardupilot.org](http://ardupilot.org).
305-
306-
This topic is a human-readable form of the XML definition file: [ardupilotmega.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/ardupilotmega.xml).
307-
308-
> **Warning** The ArduPilot MAVLink fork of [ardupilotmega.xml](https://github.com/ArduPilot/mavlink/blob/master/message_definitions/v1.0/ardupilotmega.xml) may contain messages that have not yet been merged into this documentation.
309-
"""
310300
elif filename == 'development':
311301
insert_text += """
312302
# Dialect: development
@@ -315,28 +305,75 @@ def get_top_level_docs(self, filename):
315305
They should be considered a 'work in progress' and not included in production builds.
316306
317307
This topic is a human-readable form of the XML definition file: [development.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/development.xml).
308+
"""
309+
elif filename == 'test':
310+
insert_text += """
311+
# Dialect: test
312+
313+
The test dialect is used for testing XML file parsing.
314+
315+
This topic is a human-readable form of the XML definition file: [test.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/test.xml).
318316
"""
319317
elif filename == 'all':
320318
insert_text += """
321319
# Dialect: all
322320
323-
This dialect is intended to `include` all other [dialects](../messages/README.md) in the mavlink/mavlink repository (including [external dialects](https://github.com/mavlink/mavlink/tree/master/external/dialects#mavlink-external-dialects)).
321+
This dialect is intended to `include` all other [dialects](../messages/README.md) in the [mavlink/mavlink](https://github.com/mavlink/mavlink) repository (including [external dialects](https://github.com/mavlink/mavlink/tree/master/external/dialects#mavlink-external-dialects)).
324322
325323
Dialects that are in **all.xml** are guaranteed to not have clashes in messages, enums, enum ids, and MAV_CMDs.
326324
This ensure that:
327325
328326
- Systems based on these dialects can co-exist on the same MAVLink network.
329327
- A Ground Station might (optionally) use libraries generated from **all.xml** to communicate using any of the dialects.
330328
331-
> **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.
332-
A few older dialects are not included because these operate in completely closed networks or because they are only used for tests.
329+
> **Warning**
330+
>
331+
> - New dialect files in the official repository must be added to **all.xml** and restrict themselves to using ids in their own allocated range.
332+
> - Dialects should push changes to mavlink/mavlink in order to avoid potential clashes from changes to other dialects.
333+
>
334+
> A few older dialects are not included because these operate in completely closed networks or because they are only used for tests.
333335
334336
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).
335337
"""
338+
339+
elif filename == 'ardupilotmega':
340+
insert_text += """
341+
# Dialect: ArduPilotMega
342+
343+
> **Warning** [ardupilotmega.xml](https://github.com/ArduPilot/mavlink/blob/master/message_definitions/v1.0/ardupilotmega.xml) contains the accurate and up-to-date documentation for this dialect.
344+
> The documentation below may not be accurate if the dialect owner has not pushed changes.
345+
346+
These messages define the [ArduPilot](http://ardupilot.org) specific dialect (as pushed to the [mavlink/mavlink](https://github.com/mavlink/mavlink) GitHub repository by the dialect owner).
347+
348+
This topic is a human-readable form of the XML definition file: [ardupilotmega.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/ardupilotmega.xml).
349+
350+
"""
351+
352+
elif filename == 'cubepilot':
353+
insert_text += """
354+
# Dialect: cubepilot
355+
356+
> **Warning** [cubepilot.xml](https://github.com/CubePilot/mavlink/blob/master/message_definitions/v1.0/cubepilot.xml) contains the accurate and up-to-date documentation for this dialect.
357+
> The documentation below may not be accurate if the dialect owner has not pushed changes.
358+
359+
These messages define the [CubePilot](http://www.cubepilot.com) specific dialect (as pushed to the [mavlink/mavlink](https://github.com/mavlink/mavlink) GitHub repository by the dialect owner).
360+
361+
This topic is a human-readable form of the XML definition file: [cubepilot.xml](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/cubepilot.xml).
362+
363+
"""
364+
365+
336366
else:
337-
insert_text += '\n# Dialect: %s' % filename.rsplit('.', 1)[0]
338-
insert_text += '\n\n*This is a human-readable form of the XML definition file: [%s](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/%s).*' % (
339-
filename, filename)
367+
dialectName = filename.rsplit('.', 1)[0]
368+
filenameXML = f'{dialectName}.xml'
369+
insert_text += f"""
370+
# Dialect: {dialectName}
371+
372+
> **Warning** This topic documents the version of the dialect file in the [mavlink/mavlink](https://github.com/mavlink/mavlink) Github repository, which may not be up to date with the file in the source repository (it is up to the dialect owner to push changes when needed).
373+
> The source repo should be listed in the comments at the top of the XML definition file listed below (but may not be).
374+
375+
This topic is a human-readable form of the XML definition file: [{filenameXML}](https://github.com/mavlink/mavlink/blob/master/message_definitions/v1.0/{filenameXML}).
376+
"""
340377
insert_text += """
341378
342379
<span id="mav2_extension_field"></span>
@@ -357,7 +394,6 @@ def get_top_level_docs(self, filename):
357394

358395
return insert_text
359396

360-
361397
class MAVDeprecated(object):
362398
def __init__(self, soup):
363399
# name, type, print_format, xml, description='', enum='', display='', units='', instance=False
@@ -564,8 +600,11 @@ def getMarkdown(self, currentDialect):
564600
# message+=f"Included from [{self.basename}](../messages/{self.basename}.md#{self.name})\n\n" # With basename (dialect name) test
565601
message += ' {#' + self.name + '}\n\n'
566602

567-
# If dialect, that's it. After this is assuming current dialect
568-
if self.basename is not currentDialect:
603+
# If it is common we include everything.
604+
# But for any other dialect we don't include the reset of the message
605+
if currentDialect == 'common':
606+
pass
607+
elif self.basename is not currentDialect:
569608
return message
570609

571610
if self.deprecated:
@@ -732,8 +771,11 @@ def getMarkdown(self, currentDialect):
732771
# message+=f"Included from [{self.basename}](../messages/{self.basename}.md#{self.name})\n\n" # With basename (dialect name) test
733772
string += ' {#' + self.name + '}\n\n'
734773

735-
# If dialect, that's it. After this is assuming current dialect
736-
if self.basename is not currentDialect:
774+
# If it is common we include everything.
775+
# But for any other dialect we don't include the reset of the message
776+
if currentDialect == 'common':
777+
pass
778+
elif self.basename is not currentDialect:
737779
return string
738780

739781
if self.deprecated:
@@ -874,10 +916,14 @@ def getMarkdown(self, currentDialect):
874916
string += " [WIP]"
875917
string += ' {#' + self.name + '}\n\n'
876918

877-
# If dialect, that's it. After this is assuming current dialect
878-
if self.basename is not currentDialect:
919+
# If it is common we include everything.
920+
# But for any other dialect we don't include the reset of the message
921+
if currentDialect == 'common':
922+
pass
923+
elif self.basename is not currentDialect:
879924
return string
880925

926+
881927
if self.deprecated:
882928
string += self.deprecated.getMarkdown() + "\n\n"
883929
if self.wip:

0 commit comments

Comments
 (0)