Skip to content

Commit

Permalink
Fix up linking to sub_html
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee committed Nov 11, 2018
1 parent 6e86479 commit c60b34b
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions doc/mavlink_gitbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
xml_message_definitions_dir_name = "../message_definitions/v1.0/"

output_dir = "./messages/"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
output_dir_html=output_dir+"_html/"
if not os.path.exists(output_dir_html):
os.makedirs(output_dir_html)


# File for index
index_file_name = "README.md"
Expand Down Expand Up @@ -98,6 +100,8 @@ def inject_top_level_docs(input_html,filename):
insert_text+='\n\n<span id="mav2_extension_field"></span>\n> **Note** MAVLink 2 extension fields that have been added to MAVLink 1 messages are displayed in blue.'
style_text='\n\n<style>\ntd {\n vertical-align:top;\n}\n</style>'
insert_text+=style_text
# Include HTML in generated content
insert_text+='\n\n{%% include "_html/%s.html" %%}' % filename[:-4]
input_html=insert_text+'\n\n'+input_html


Expand Down Expand Up @@ -126,25 +130,38 @@ def inject_top_level_docs(input_html,filename):
prettyHTML=strip_text_before_string(prettyHTML,'<html>')
prettyHTML = fix_content_in_tags(prettyHTML)

#Inject a heading and doc-type intro (markdown format)
prettyHTML = inject_top_level_docs(prettyHTML,file)

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

#Replace space markers with intentional space
prettyHTML = fix_replace_space_marker(prettyHTML)

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

output_file_name_html_withdir = output_dir_html+output_file_name_html
print("Output filename (html): %s" % output_file_name_html)

with open(output_file_name_html_withdir, 'w') as out:
out.write(prettyHTML)


#Write output markdown file
output_file_name = file.rsplit('.',1)[0]+".md"
output_file_name_withdir = output_dir+output_file_name
print("Output filename: %s" % output_file_name)
output_file_name_md = file.rsplit('.',1)[0]+".md"

markdown_text=''
#Inject a heading and doc-type intro (markdown format)
markdown_text = inject_top_level_docs(markdown_text,file)

output_file_name_md_withdir = output_dir+output_file_name_md
print("Output filename (md): %s" % output_file_name_md)

with open(output_file_name_md_withdir, 'w') as out:
out.write(markdown_text)

with open(output_file_name_withdir, 'w') as out:
out.write(prettyHTML )

#if not file=='common.xml':
index_text+='\n* [%s](%s)' % (file,output_file_name)
index_text+='\n* [%s](%s)' % (file,output_file_name_md)

#Write the index - Disabled for now.
with open(index_file_name, 'w') as content_file:
Expand Down

0 comments on commit c60b34b

Please sign in to comment.