-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fixes #7844: Integrate ncf generic methods reference into the doc #170
Merged
jooooooon
merged 1 commit into
Normation:branches/rudder/2.11
from
amousset:ust_7844/integrate_ncf_generic_methods_reference_into_the_doc
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
=== Generic methods | ||
|
||
include::../generic_methods.asciidoc[] |
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
## Rudder User Documentation Makefile | ||
|
||
.PHONY: all clean view | ||
.PHONY: all clean view ncf-doc | ||
|
||
BASENAME = rudder-doc | ||
SOURCES = $(BASENAME).txt | ||
TARGETS = epub html pdf readme webhelp webhelp-localsearch | ||
DOCBOOK_DIST = xsl/xsl-ns-stylesheets | ||
|
||
NCF_VERSION = v0.x | ||
|
||
ASCIIDOC = $(CURDIR)/bin/asciidoc/asciidoc.py | ||
A2X = $(CURDIR)/bin/asciidoc/a2x.py | ||
|
||
|
@@ -54,6 +56,7 @@ webhelp-localsearch: webhelp-localsearch/index.html index | |
html: html/$(BASENAME).html | ||
pdf: html/$(BASENAME).pdf | ||
readme: html/README.html | ||
ncf-doc: generic-methods.asciidoc | ||
|
||
epub/$(BASENAME).epub: $(SOURCES) | ||
mkdir -p html | ||
|
@@ -68,6 +71,15 @@ html/$(BASENAME).pdf: $(SOURCES) | |
rm -f *.svg | ||
mv $(BASENAME).pdf html/ | ||
|
||
ncf: | ||
git clone https://github.com/Normation/ncf.git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same mechanism as rudder-agent repo for man in 3.0+. |
||
|
||
generic-methods.asciidoc: ncf | ||
cd ncf && git pull && git checkout $(NCF_VERSION) | ||
cp tools/ncf_doc_rudder.py ncf/tools/ | ||
./ncf/tools/ncf_doc_rudder.py | ||
pandoc -t asciidoc -f markdown generic_methods.md > generic_methods.asciidoc | ||
|
||
$(INDEXER_JAR): | ||
mkdir -p $(DOCBOOK_EXTENSIONS_DIR) | ||
wget http://central.maven.org/maven2/net/sf/docbook/docbook-xsl-webhelpindexer/1.0.1-pre/docbook-xsl-webhelpindexer-1.0.1-pre.jar -O $(INDEXER_JAR) | ||
|
@@ -86,9 +98,9 @@ $(LUCENE_ANALYZER_JAR): | |
|
||
jars: $(INDEXER_JAR) $(TAGSOUP_JAR) $(LUCENE_ANALYZER_JAR) $(LUCENE_CORE_JAR) | ||
|
||
webhelp/index.html: $(SOURCES) | ||
webhelp/index.html: ncf-doc $(SOURCES) | ||
mkdir -p webhelp | ||
$(ASCIIDOC) --doctype=book --backend docbook $? | ||
$(ASCIIDOC) --doctype=book --backend docbook $(SOURCES) | ||
xsltproc --xinclude --output xincluded-profiled.xml \ | ||
$(DOCBOOK_DIST)/profiling/profile.xsl $(BASENAME).xml | ||
xsltproc --stringparam webhelp.base.dir "webhelp" \ | ||
|
@@ -98,9 +110,9 @@ webhelp/index.html: $(SOURCES) | |
xsl/webhelp.xsl xincluded-profiled.xml | ||
cp -r style/html/favicon.ico images template/common *.png webhelp/ | ||
|
||
webhelp-localsearch/index.html: $(SOURCES) | ||
webhelp-localsearch/index.html: ncf-doc $(SOURCES) | ||
mkdir -p webhelp-localsearch | ||
$(ASCIIDOC) --doctype=book --backend docbook $? | ||
$(ASCIIDOC) --doctype=book --backend docbook $(SOURCES) | ||
xsltproc --xinclude --output xincluded-profiled.xml \ | ||
$(DOCBOOK_DIST)/profiling/profile.xsl $(BASENAME).xml | ||
xsltproc --stringparam webhelp.base.dir "webhelp-localsearch" \ | ||
|
@@ -123,22 +135,22 @@ index: webhelp-localsearch/index.html jars | |
com.nexwave.nquindexer.IndexerMain | ||
cp -r template/search/* webhelp-localsearch/search | ||
|
||
html/$(BASENAME).html: $(SOURCES) | ||
html/$(BASENAME).html: ncf-doc $(SOURCES) | ||
mkdir -p html | ||
$(ASCIIDOCTOHTML) --out-file $@ $? | ||
$(ASCIIDOCTOHTML) --out-file $@ $(SOURCES) | ||
cp -R style/html/* images html/ | ||
|
||
html/README.html: README.asciidoc | ||
mkdir -p html | ||
$(ASCIIDOCTOHTML) --out-file $@ $? | ||
|
||
slides.html: $(SOURCES) | ||
$(ASCIIDOC) -a theme=volnitsky --out-file slides.html --backend slidy $? | ||
$(ASCIIDOC) -a theme=volnitsky --out-file slides.html --backend slidy $(SOURCES) | ||
|
||
## WARNING: at cleanup, delete png files that were produced by output only ! | ||
|
||
clean: | ||
rm -rf rudder-doc.xml *.pdf *.html *.png *.svg temp html epub webhelp webhelp-localsearch xincluded-profiled.xml $(BASENAME).xml extensions | ||
rm -rf rudder-doc.xml *.pdf *.html *.png *.svg temp html epub webhelp webhelp-localsearch xincluded-profiled.xml $(BASENAME).xml extensions ncf generic_methods.{asciidoc,md} | ||
|
||
view: all | ||
$(SEE) $(TARGETS) |
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,104 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Usage: ./ncf_doc_rudder.py | ||
# | ||
# This is a Python module to generate documentation from generic methods in ncf to be embedded in Rudder manual | ||
|
||
import ncf | ||
import requests | ||
import sys | ||
import re | ||
from distutils.version import StrictVersion | ||
from pprint import pprint | ||
|
||
# URL of the rudder_info api | ||
release_info_url = "http://www.rudder-project.org/release-info/rudder/" | ||
|
||
def get_min_versions(): | ||
"Build the dictionnary of minimal Rudder version including compatibility with a given CFEngine version" | ||
min_version = {} | ||
|
||
try: | ||
versions = requests.get(release_info_url + "versions").content.decode('ascii').splitlines() | ||
except requests.exceptions.RequestException as e: | ||
print(e) | ||
sys.exit(1) | ||
|
||
for rudder_version in versions: | ||
try: | ||
cfengine_version = requests.get(release_info_url + "versions/" + rudder_version + "/components/cfengine").content.decode('ascii') | ||
except requests.exceptions.RequestException as e: | ||
print(e) | ||
sys.exit(1) | ||
|
||
if cfengine_version in min_version: | ||
if StrictVersion(rudder_version) >= StrictVersion(min_version[cfengine_version]): | ||
continue | ||
min_version[cfengine_version] = rudder_version | ||
|
||
return min_version | ||
|
||
def rudder_version(min_version, version): | ||
"""Extract minimal Rudder version""" | ||
canonified_version = re.findall(r'>=? ?(\d+\.\d+)', version)[0] | ||
|
||
cfengine_versions = list(min_version.keys()) | ||
cfengine_versions.sort(key=StrictVersion) | ||
|
||
for cfengine_version in cfengine_versions: | ||
if StrictVersion(canonified_version) <= StrictVersion(cfengine_version): | ||
return min_version[cfengine_version] | ||
return False | ||
|
||
|
||
if __name__ == '__main__': | ||
# Get CFEngine <=> Rudder versions | ||
versions = get_min_versions() | ||
|
||
# Get all generic methods | ||
generic_methods = ncf.get_all_generic_methods_metadata()["data"] | ||
|
||
categories = {} | ||
for method_name in sorted(generic_methods.keys()): | ||
category_name = method_name.split('_',1)[0] | ||
generic_method = generic_methods[method_name] | ||
if (category_name in categories): | ||
categories[category_name].append(generic_method) | ||
else: | ||
categories[category_name] = [generic_method] | ||
|
||
content = [] | ||
|
||
for category in sorted(categories.keys()): | ||
content.append("\n*****\n") | ||
content.append('\n### '+category.title()) | ||
|
||
# Generate markdown for each generic method | ||
for generic_method in categories[category]: | ||
# do not display generic methods not compatible with a released Rudder version | ||
rudder_version_needed = rudder_version(versions, generic_method["agent_version"]) | ||
if not rudder_version_needed: | ||
continue | ||
content.append("\n*****\n") | ||
bundle_name = generic_method["bundle_name"] | ||
content.append('\n#### '+ bundle_name) | ||
content.append(generic_method["description"]) | ||
content.append('\nCompatible with nodes running Rudder '+rudder_version_needed+' or higher.') | ||
|
||
if "documentation" in generic_method: | ||
content.append('\n##### Usage') | ||
content.append(generic_method["documentation"]) | ||
content.append('\n##### Parameters') | ||
for parameter in generic_method["parameter"]: | ||
content.append("* **" + parameter['name'] + "**: " + parameter['description']) | ||
content.append('\n##### Classes defined') | ||
content.append('\n```\n') | ||
content.append(generic_method["class_prefix"]+"_${"+generic_method["class_parameter"] + "}_{kept, repaired, not_ok, reached}") | ||
content.append('\n```\n') | ||
|
||
# Write generic_methods.md | ||
result = '\n'.join(content)+"\n" | ||
outfile = open("generic_methods.md","w") | ||
outfile.write(result) | ||
outfile.close() |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to do another PR to change this to master in 3.2+