Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Markdown (and other) module doc output #3220

Merged
merged 1 commit into from
Jun 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions hacking/module_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import time
import datetime
import subprocess
import cgi
import ansible.utils
import ansible.utils.module_docs as module_docs

Expand Down Expand Up @@ -62,11 +63,13 @@ def latex_ify(text):

def html_ify(text):

t = _ITALIC.sub("<em>" + r"\1" + "</em>", text)
t = cgi.escape(text)
t = _ITALIC.sub("<em>" + r"\1" + "</em>", t)
t = _BOLD.sub("<b>" + r"\1" + "</b>", t)
t = _MODULE.sub("<span class='module'>" + r"\1" + "</span>", t)
t = _URL.sub("<a href='" + r"\1" + "'>" + r"\1" + "</a>", t)
t = _CONST.sub("<code>" + r"\1" + "</code>", t)

return t

def json_ify(text):
Expand Down Expand Up @@ -105,9 +108,13 @@ def rst_ify(text):

return t

_MARKDOWN = re.compile(r"[*_`]")

def markdown_ify(text):

t = _ITALIC.sub("_" + r"\1" + "_", text)
t = cgi.escape(text)
t = _MARKDOWN.sub(r"\\\g<0>", t)
t = _ITALIC.sub("_" + r"\1" + "_", t)
t = _BOLD.sub("**" + r"\1" + "**", t)
t = _MODULE.sub("*" + r"\1" + "*", t)
t = _URL.sub("[" + r"\1" + "](" + r"\1" + ")", t)
Expand Down
9 changes: 7 additions & 2 deletions hacking/templates/markdown.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## @{ module }@
## @{ module | jpfunc }@

{# ------------------------------------------
#
Expand All @@ -11,7 +11,8 @@ New in version @{ version_added }@.
{% endif %}

{% for desc in description -%}
@{ desc | jpfunc }@
@{ desc | jpfunc }@

{% endfor %}

{% if options -%}
Expand All @@ -35,6 +36,10 @@ New in version @{ version_added }@.
</table>
{% endif %}

{% if examples or plainexamples %}
#### Examples
{% endif %}

{% for example in examples %}
{% if example['description'] %}
* @{ example['description'] | jpfunc }@
Expand Down