forked from Normation/rudder-doc
-
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.
- Loading branch information
Showing
11 changed files
with
173 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ doc.iml | |
|
||
# Temporary | ||
doc-build | ||
changelogs-build |
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
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 |
---|---|---|
|
@@ -14,4 +14,6 @@ content: | |
- url: . | ||
branches: HEAD | ||
start_path: src/reference | ||
|
||
- url: . | ||
branches: HEAD | ||
start_path: src/changelogs |
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,4 @@ | ||
modules/*/nav.adoc | ||
modules/*/pages/_partials/dyn/ | ||
modules/*/assets/images/graphviz/ | ||
modules/plugins/assets/ |
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,20 @@ | ||
## Rudder Changelog Makefile | ||
|
||
.PHONY: clean nav | ||
|
||
## Dynamic content | ||
|
||
changelogs: | ||
cd dependencies && make $@ | ||
cp -r dependencies/$@/* modules/ROOT/pages/ | ||
mv modules/ROOT/pages/main.adoc modules/ROOT/pages/index.adoc | ||
echo "* xref:index.adoc[Main changelogs]" > modules/ROOT/nav.adoc | ||
echo "* Plugins" >> modules/ROOT/nav.adoc | ||
find modules/ROOT/pages/plugins -type f | sed 's/.*\///' | sed "s/\.adoc//" | sed -r 's@(.*)@** xref:plugins/\1.adoc[\1]@' | sort >> modules/ROOT/nav.adoc | ||
|
||
## Clean | ||
|
||
clean: | ||
cd dependencies && make clean | ||
rm -rf modules/*/nav.adoc | ||
rm -rf modules/*/pages/* |
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,6 @@ | ||
name: changelogs | ||
title: Changelogs | ||
version: "5.0" | ||
nav: | ||
- modules/ROOT/nav.adoc | ||
|
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 @@ | ||
# Generated files | ||
/changelogs/ | ||
/rudder-tools-repo/ |
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 @@ | ||
## Builds dynamic dependencies from other repos | ||
|
||
RUDDER_VERSION = 5.0 | ||
|
||
.PHONY: clean changelogs | ||
all: changelogs | ||
|
||
## Repos | ||
|
||
rudder-tools-repo: | ||
git clone https://github.com/Normation/rudder-tools.git rudder-tools-repo | ||
|
||
## Dynamic content | ||
|
||
changelogs: rudder-tools-repo | ||
cd rudder-tools-repo && git checkout master | ||
cd rudder-tools-repo && git pull | ||
mkdir -p changelogs | ||
cp -r rudder-tools-repo/release-data/changelogs/$(RUDDER_VERSION)/* changelogs/ | ||
|
||
## Clean | ||
|
||
clean: | ||
rm -rf changelogs | ||
|
||
veryclean: clean | ||
rm -rf changelogs rudder-tools-repo |
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,72 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
MODULE = sys.argv[1] | ||
NAME = sys.argv[2] | ||
|
||
MODULEDIR = "modules/"+MODULE | ||
PAGESDIR = MODULEDIR+"/pages/" | ||
TITLE = re.compile("^(=+) (.+)$") | ||
ID = re.compile(r"^\[\[(.+),?.*\]\]$") | ||
|
||
def remove_duplicate_underscore(string): | ||
prev = ' ' | ||
res = [] | ||
for char in string: | ||
if prev == '_' and char == '_': | ||
pass | ||
else: | ||
res.append(char) | ||
prev = char | ||
return ''.join(res) | ||
|
||
# reproduce asciidoc's behavior | ||
def slugify(s): | ||
s = "_" + s | ||
s = s.lower() | ||
s = s.strip() | ||
s = re.sub('\W', '_', s) | ||
s = remove_duplicate_underscore(s) | ||
s = s.rstrip('_') | ||
return s | ||
|
||
# Get all standalone .adoc pages, sorted alphanumerically | ||
# We exclude files in root (the index of the doc), _partials which are not actual pages | ||
|
||
with open(MODULEDIR + "/nav.list") as f: | ||
files = f.read().splitlines() | ||
#files = sorted([file for root, dirs, files in os.walk('.') for file in files if file.endswith(".adoc") and not "_partials" in root]) | ||
#files = sorted([root.split('/', 1)[-1]+"/"+file for root, dirs, files in os.walk('.') for file in files if file.endswith(".adoc") and not "_partials" in root]) | ||
|
||
result = ["// Automatically generated list of content - do not edit", "* "+NAME] | ||
|
||
os.chdir(PAGESDIR) | ||
|
||
for file in files: | ||
with open(file) as f: | ||
content = f.read().splitlines() | ||
|
||
prev = "" | ||
first = True | ||
for line in content: | ||
search_title = TITLE.search(line) | ||
if search_title: | ||
level = search_title.group(1).count("=") + 1 | ||
title = search_title.group(2) | ||
search_id = ID.search(prev) | ||
if search_id: | ||
page_id = search_id.group(1) | ||
else: | ||
page_id = slugify(title) | ||
if level < 4: | ||
if first: | ||
result.append("*" * level + " xref:" + file + "[" + title + "]") | ||
first = False | ||
else: | ||
result.append("*" * level + " xref:" + file + "#" + page_id + "[" + title + "]") | ||
prev = line | ||
|
||
print("\n".join(result)) |