From ba370b178d267bb5976a8da925be482ade7b7f3b Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Sat, 24 Feb 2018 03:57:37 +0100 Subject: [PATCH] docsite: Add 'Edit on GitHub' for module docs (#36667) This is something I always wanted, a 'Edit on GitHub' button for module documentation. I also removed the additional statement in the footer with instructions on how to edit the module documentation. PS The links go directly into the GitHub file editor now ! --- docs/bin/plugin_formatter.py | 2 ++ docs/docsite/_themes/sphinx_rtd_theme/breadcrumbs.html | 8 ++++++-- docs/docsite/_themes/srtd/breadcrumbs.html | 2 +- docs/docsite/_themes/srtd/footer.html | 4 ++-- docs/templates/plugin.rst.j2 | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/bin/plugin_formatter.py b/docs/bin/plugin_formatter.py index 603290e5077..4d630bfdfa0 100755 --- a/docs/bin/plugin_formatter.py +++ b/docs/bin/plugin_formatter.py @@ -240,6 +240,7 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False): # save all the information module_info[module] = {'path': module_path, + 'source': os.path.relpath(module_path, module_dir), 'deprecated': deprecated, 'aliases': set(), 'metadata': metadata, @@ -413,6 +414,7 @@ def process_plugins(module_map, templates, outputname, output_dir, ansible_versi doc['option_keys'] = option_names doc['filename'] = fname + doc['source'] = module_map[module]['source'] doc['docuri'] = doc['module'].replace('_', '-') doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d') doc['ansible_version'] = ansible_version diff --git a/docs/docsite/_themes/sphinx_rtd_theme/breadcrumbs.html b/docs/docsite/_themes/sphinx_rtd_theme/breadcrumbs.html index c052c0bde1d..7e901ab98ef 100644 --- a/docs/docsite/_themes/sphinx_rtd_theme/breadcrumbs.html +++ b/docs/docsite/_themes/sphinx_rtd_theme/breadcrumbs.html @@ -1,9 +1,13 @@ diff --git a/docs/docsite/_themes/srtd/breadcrumbs.html b/docs/docsite/_themes/srtd/breadcrumbs.html index c052c0bde1d..8cb48a6f40b 100644 --- a/docs/docsite/_themes/srtd/breadcrumbs.html +++ b/docs/docsite/_themes/srtd/breadcrumbs.html @@ -3,7 +3,7 @@
  • {{ title }}
  • {% if not pagename.endswith('_module') and (not 'list_of' in pagename) and (not 'category' in pagename) %}
  • - Edit on GitHub + Edit on GitHub
  • {% endif %} diff --git a/docs/docsite/_themes/srtd/footer.html b/docs/docsite/_themes/srtd/footer.html index 55ca16a8483..c7e1e0cb636 100644 --- a/docs/docsite/_themes/srtd/footer.html +++ b/docs/docsite/_themes/srtd/footer.html @@ -22,7 +22,7 @@

    - Copyright © 2017 Red Hat, Inc. + Copyright © 2018 Red Hat, Inc.
    {%- if last_updated %} @@ -30,6 +30,6 @@ {%- endif %}

    -Ansible docs are generated from GitHub sources using Sphinx using a theme provided by Read the Docs. {% if pagename.endswith("_module") %}Module documentation is not edited directly, but is generated from the source code for the modules. To submit an update to module docs, edit the 'DOCUMENTATION' metadata in the modules directory of the core source code repository. {% endif %} +Ansible docs are generated from GitHub sources using Sphinx using a theme provided by Read the Docs.

    diff --git a/docs/templates/plugin.rst.j2 b/docs/templates/plugin.rst.j2 index 8f25b26bdc2..cea36c4f929 100644 --- a/docs/templates/plugin.rst.j2 +++ b/docs/templates/plugin.rst.j2 @@ -1,3 +1,5 @@ +:source: @{ source }@ + .. _@{ module }@: {% if short_description %}