From da6275e43a54e11dd6fd7ccaa7e40822551a3628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 28 Jul 2021 22:05:26 +0200 Subject: [PATCH] msg: add script structure to generate docs from .msg files --- Jenkinsfile | 20 +++++++++++++++++++ msg/tools/generate_msg_docs.py | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 msg/tools/generate_msg_docs.py diff --git a/Jenkinsfile b/Jenkinsfile index df10e02a7a..5449525611 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -143,6 +143,24 @@ pipeline { } } + stage('msg files') { + agent { + docker { image 'px4io/px4-dev-base-focal:2021-05-04' } + } + steps { + sh './msg/tools/generate_msg_docs.py -d /tmp/msg_docs' + dir('/tmp') { + archiveArtifacts(artifacts: 'msg_docs/*.md') + stash includes: 'msg_docs/*.md', name: 'msg_documentation' + } + } + post { + always { + sh 'make distclean' + } + } + } + stage('uORB graphs') { agent { docker { @@ -183,11 +201,13 @@ pipeline { unstash 'metadata_airframes' unstash 'metadata_parameters' unstash 'metadata_module_documentation' + unstash 'msg_documentation' withCredentials([usernamePassword(credentialsId: 'px4buildbot_github_personal_token', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) { sh('git clone https://${GIT_USER}:${GIT_PASS}@github.com/PX4/px4_user_guide.git') sh('cp airframes.md px4_user_guide/en/airframes/airframe_reference.md') sh('cp parameters.md px4_user_guide/en/advanced_config/parameter_reference.md') sh('cp -R modules/*.md px4_user_guide/en/modules/') + sh('cp -R msg_docs/*.md px4_user_guide/en/msg_docs/') sh('cd px4_user_guide; git status; git add .; git commit -a -m "Update PX4 Firmware metadata `date`" || true') sh('cd px4_user_guide; git push origin master || true') sh('rm -rf px4_user_guide') diff --git a/msg/tools/generate_msg_docs.py b/msg/tools/generate_msg_docs.py new file mode 100755 index 0000000000..3bbbef2fa3 --- /dev/null +++ b/msg/tools/generate_msg_docs.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +""" +Generate docs from .msg files +""" + +import os +import argparse +import sys + + +def get_msgs_list(msgdir): + """ + Makes list of msg files in the given directory + """ + return [fn for fn in os.listdir(msgdir) if fn.endswith(".msg")] + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Generate docs from .msg files') + parser.add_argument('-d', dest='dir', help='output directory', required=True) + args = parser.parse_args() + + output_dir = args.dir + if not os.path.isdir(output_dir): + os.mkdir(output_dir) + + msg_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"..") + msg_files = get_msgs_list(msg_path) + for msg_file in msg_files: + msg_name = os.path.splitext(msg_file)[0] + output_file = os.path.join(output_dir, msg_name+'.md') + msg_filename = os.path.join(msg_path, msg_file) + print("{:} -> {:}".format(msg_filename, output_file)) +