forked from debops/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote scripts to generate: * Ansible modules * DebOps roles (likes to GitHub repo) * DebOps Contrib roles (likes to GitHub repo) * ypid roles (likes to GitHub repo, seamless self plug. Added my private Ansible roles for reference.) Implements: debops#155 Usage for roles (or other DebOps repos): Create `./docs/includes/all.rst`: ```rst .. include:: includes/global.rst ``` Ensure line present in `.gitignore`: ```rst docs/includes/global.rst ``` Copy https://github.com/debops/docs/tree/master/docs/includes/global.rst to `docs/includes/global.rst` Use in docs like so (example `docs/getting-started.rst`): ```rst Getting started =============== .. contents:: :local: .. include:: includes/all.rst DebOps_ rocks! .. ↑ makes it a hyperlink. ``` Thats all. Enjoy 😉
- Loading branch information
Showing
11 changed files
with
1,664 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
## @author Copyright (C) 2016 Robin Schneider <ypid@riseup.net> | ||
## @license GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.html> | ||
|
||
## Generate URL definitions of all Ansible modules in RST. | ||
|
||
set -e | ||
|
||
echo '.. Ansible modules [[[ | ||
.. This section was generated by: https://github.com/debops/docs/blob/master/docs/docs/bin/gen_ansible_modules_rst_defs | ||
' | ||
|
||
## dev/testing: `ansible-doc -l` needs to be cached because it is that freaking slow. | ||
# test -f "/tmp/ansible_module.list" || ansible-doc -l 2>/dev/null > "/tmp/ansible_module.list" | ||
# cut -d ' ' -f 1 "/tmp/ansible_module.list" | while read -r ansible_module_name | ||
|
||
ansible-doc -l 2>/dev/null | cut -d ' ' -f 1 | while read -r ansible_module_name | ||
do | ||
if [[ "$ansible_module_name" == "DEPRECATED:" ]] | ||
then | ||
echo "Deprecated modules follow:" | ||
else | ||
echo ".. _Ansible ${ansible_module_name} module: https://docs.ansible.com/ansible/${ansible_module_name}_module.html" | ||
fi | ||
done | ||
|
||
echo '.. ]]]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
## @author Copyright (C) 2016 Robin Schneider <ypid@riseup.net> | ||
## @license GPL-3.0 <https://www.gnu.handle/licenses/gpl-3.0.html> | ||
|
||
## Generate URL definitions based on data returned by remote API. | ||
|
||
set -e | ||
|
||
SCRIPT_URL='https://github.com/debops/docs/blob/master/docs/docs/bin/gen_rst_defs_using_remote_api' | ||
|
||
get_defs_by_github_api_call() { | ||
## Ref: https://developer.github.com/v3/repos/#list-user-repositories | ||
handle_name="$1" | ||
handle_id="$2"; | ||
|
||
## Choices: orgs, users | ||
mode="${3:-orgs}" | ||
|
||
github_api_url="https://api.github.com/$mode/$handle_id/repos" | ||
# echo "$github_api_url" | ||
test -f "/tmp/${handle_id}.json" || curl --silent "$github_api_url" > "/tmp/${handle_id}.json" | ||
|
||
echo ".. $handle_name repositories [[[" | ||
echo ".. This section was generated by: $SCRIPT_URL" | ||
echo "" | ||
|
||
jq --raw-output '.[].name' "/tmp/${handle_id}.json" | while read -r repo_name | ||
do | ||
case $repo_name in | ||
ansible-*) | ||
role_name="${repo_name#ansible-}" | ||
if [[ $role_name =~ .*-.* ]] | ||
then | ||
## Don’t include roles with legacy naming scheme. | ||
continue | ||
fi | ||
echo ".. _${handle_id}.${role_name}: https://github.com/$handle_id/$repo_name" | ||
;; | ||
esac | ||
done | ||
|
||
echo '.. ]]]' | ||
} | ||
|
||
case $1 in | ||
github) | ||
get_defs_by_github_api_call "$2" "$3" "$4" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
## @author Copyright (C) 2016 Robin Schneider <ypid@riseup.net> | ||
## @license GPL-3.0 <https://www.gnu.org/licenses/gpl-3.0.html> | ||
|
||
## Link the global.rst include file into all parts of DebOps which use it. | ||
|
||
set -e | ||
|
||
test -f "includes/global.rst" || exit 1 | ||
|
||
DOCS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" | ||
|
||
find . -type d -name 'includes' -not -iwholename './includes' | while read -r target_include_dir | ||
do | ||
pushd "$target_include_dir" | ||
ln -rsf "$DOCS_DIR/includes/global.rst" global.rst | ||
popd | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. vim: foldmarker=[[[,]]]:foldmethod=marker | ||
.. Generated by the scripts contained in https://github.com/debops/docs/tree/master/docs/includes/global.rst | ||
.. This file is possible copied to multiple git repositories. | ||
.. Ansible core [[[ | ||
.. _Ansible: https://www.ansible.com/ | ||
|
||
.. ]]] |
Oops, something went wrong.