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

User manual including toolchain for auto-generation #370

Merged
merged 98 commits into from
Aug 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
3b6ea90
initial checkin of api doc + manual test
peuter Aug 14, 2016
7e01922
add more examples
peuter Aug 14, 2016
82e45fe
add more examples
peuter Aug 14, 2016
02f412c
- start spinx build system
peuter Aug 14, 2016
c2adc69
- fix api-doc generation
peuter Aug 14, 2016
0a6e7e1
ignore screenshots
peuter Aug 14, 2016
94da3ba
cleanup
peuter Aug 14, 2016
2d7b900
change path
peuter Aug 14, 2016
03709fa
backup commit
peuter Aug 15, 2016
e02b48f
fix screenshot example generation
peuter Aug 15, 2016
e53ea23
add missing examples
peuter Aug 15, 2016
55c8987
replace XXX with widgets name
peuter Aug 15, 2016
820db30
start implementation of automatic XSD information retrieval
peuter Aug 16, 2016
942cf55
fix code highlighting
peuter Aug 16, 2016
8f180e5
syntax fix
peuter Aug 16, 2016
31d48d5
remove empty chapter
peuter Aug 16, 2016
56d4ca0
refactoring
peuter Aug 16, 2016
dd4ccc5
add translation
peuter Aug 17, 2016
6f2be79
fix editor screenshots
peuter Aug 18, 2016
2846dda
allow cropping of screenshots
peuter Aug 18, 2016
90728ce
more todos to readme
peuter Aug 18, 2016
d2edde5
hide-source fix
peuter Aug 18, 2016
3a5f113
- add some basic structure
peuter Aug 19, 2016
f5d48b0
screenshot updates
peuter Aug 19, 2016
be772d2
changes for deployment script
peuter Aug 20, 2016
7c0bf44
add encypted deploy key
peuter Aug 20, 2016
bebec4e
add deployment script
peuter Aug 20, 2016
7d230bd
some changes
peuter Aug 20, 2016
27ed8ac
make sure that the deploy_key does not get commited
peuter Aug 20, 2016
b1e89b1
use the right path
peuter Aug 20, 2016
b356c18
setup doc build environment
peuter Aug 20, 2016
1dd3fd4
use python3
peuter Aug 20, 2016
58725c4
try to make plantuml installable
peuter Aug 20, 2016
e389539
add missing dep
peuter Aug 20, 2016
20af830
add encoding to python source files
peuter Aug 20, 2016
de0b7ac
use firefox for screenshots on travis
peuter Aug 20, 2016
b10b686
some changes to allow browserName to be changed
peuter Aug 20, 2016
59be562
install easyimage package
peuter Aug 20, 2016
7ad4f0e
fir parameter
peuter Aug 20, 2016
4866b95
use the correct install tool
peuter Aug 20, 2016
ae0dbf4
cleanup
peuter Aug 20, 2016
6f56b45
add some debugging code
peuter Aug 20, 2016
dceab77
split into single tasks
peuter Aug 20, 2016
091300d
use the right task
peuter Aug 20, 2016
5978426
remove generation from deploy script, let travis do the single tasks
peuter Aug 20, 2016
90a5ff9
some update to test the build/deployment
peuter Aug 20, 2016
68a948d
some update to test the build/deployment
peuter Aug 20, 2016
bbfb898
reactive deployment
peuter Aug 20, 2016
384d063
and back to the deploy again
peuter Aug 20, 2016
76c15a2
another try
peuter Aug 20, 2016
eb71e06
structural change
peuter Aug 20, 2016
1d167cf
show some dirs
peuter Aug 20, 2016
0ae0184
another try
peuter Aug 20, 2016
53a8224
allow removal of files when commiting generated docs
peuter Aug 20, 2016
5e14f6c
try to fix api doc links to screenshots
peuter Aug 20, 2016
9bef49c
we're getting closer
peuter Aug 20, 2016
e5168ed
we're getting closer
peuter Aug 20, 2016
cc6dcdd
add xml lang hint to examples
peuter Aug 21, 2016
97af007
add the lang hint after caption
peuter Aug 21, 2016
d208165
delete api doc from repo as it is hosted in the gh-pages branch
peuter Aug 21, 2016
97ef2f1
hide toctree
peuter Aug 21, 2016
fe94a09
print invalid config
peuter Aug 21, 2016
e9d6502
check version
peuter Aug 21, 2016
9de9eb7
change language
peuter Aug 21, 2016
67a7024
use python3
peuter Aug 21, 2016
2c35275
delete screenshots
peuter Aug 21, 2016
aeeed85
delete markdown test files
peuter Aug 21, 2016
1835f4b
install pip3
peuter Aug 21, 2016
00ab5a4
use another distribution
peuter Aug 21, 2016
4713d81
another try to install pip3
peuter Aug 21, 2016
c4c7116
another try to install pip3
peuter Aug 21, 2016
bc847bb
gmrpf
peuter Aug 21, 2016
f6c70e7
check
peuter Aug 21, 2016
5bd8bde
check
peuter Aug 21, 2016
f5d9299
remove python2 code does not work
peuter Aug 21, 2016
1003590
revert changes
peuter Aug 21, 2016
10b1169
show version
peuter Aug 22, 2016
c8ef779
another try
peuter Aug 22, 2016
99e57fe
upgrade
peuter Aug 22, 2016
d741d25
upgrade
peuter Aug 22, 2016
675d3a5
remove auto-generated files
peuter Aug 22, 2016
65bb959
remove line
peuter Aug 22, 2016
4e9a254
disable plantuml for now
peuter Aug 22, 2016
7967e34
disable plantuml for now
peuter Aug 22, 2016
3be5348
refactor widget example structure to allow simple c&p from real configs
peuter Aug 22, 2016
63e837b
try to install plantuml manually
peuter Aug 22, 2016
5f7aa27
fullfill dependency
peuter Aug 22, 2016
ff698c5
remove xsltproc from build
peuter Aug 22, 2016
5671b89
remove finished TODOs
peuter Aug 22, 2016
587fc5b
allow api-doc to create only jsdoc screenshots
peuter Aug 22, 2016
d73ea94
try to use chrome for screenshots
peuter Aug 22, 2016
4bfa8d0
try to use chrome for screenshots
peuter Aug 22, 2016
d07ca85
make it executable
peuter Aug 22, 2016
736566f
a little bit more tweaking
peuter Aug 22, 2016
f728b2e
some cleanup + re-added the auto-generated widget pages again
peuter Aug 22, 2016
2458943
change paths
peuter Aug 22, 2016
751e992
add wip hint
peuter Aug 22, 2016
451b0f4
change deployment branch
peuter Aug 22, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Setup documentation build system
--------------------------------

Source docs
-----------
Install required packages
```
npm install jsdoc libxmljs-mt libxml-xsd easyimage
```

generate doc with
```
grunt apt-doc
```

User Manual
-----------
Install libxml2, libxslt development files and plantuml (e.g. `apt-get install libxml2-dev libxslt-dev plantuml`)
Install required python3 packages specified in .doc/docutils/requirements.txt
Note: pip install sh must be installed as root `sudo pip install sh`
(and python3 if it is not installed on your system)

generate doc with:
```
sphinx-build -b html doc/manual/de/rst/ doc/manual/de/html
```

Translation
-----------
```
# update po files
pygettext -d cv -p locale/ .doc/docutils/directives/*.py
# translate with poedit + save
```

TODOs
-----

TODO: possibility to map attribute names to links
TODO: improve element description retrieval from XSD, possibility to extend
TODO: transfer content from wiki
TODO: establish structure for manual (done for widgets)
TODO: cleanup, doc

Optional
--------

* auto-generate english widget descriptions from jsdoc
Empty file added .doc/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions .doc/browser-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ "$CV_BROWSER" = "" ]; then
exit 0
fi

if [ $CV_BROWSER = Firefox ]; then
wget -O /tmp/firefox.tar.bz2 "https://download.mozilla.org/?product=firefox-${CV_VERSION}&lang=en-US&os=linux64"
tar xf /tmp/firefox.tar.bz2
else
wget -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-${CV_VERSION}_current_amd64.deb
dpkg --extract /tmp/chrome.deb chrome-x
if [ $CV_VERSION = stable ]; then
mv chrome-x/opt/google/chrome chrome
mv chrome/google-chrome chrome/google-chrome-stable
else
mv chrome-x/opt/google/chrome-$CV_VERSION chrome
rm chrome/google-chrome
fi
ln -s google-chrome-$CV_VERSION chrome/google-chrome
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need that file like that - or should we first check whether a browser is already installed (most likely allways the case...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no chrome installed in the travis images,so we have to install it.

70 changes: 70 additions & 0 deletions .doc/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

SOURCE_BRANCH="develop"
TARGET_BRANCH="gh-pages"

function createDocs {
sphinx-build -b html doc/manual/de out/de/manual
grunt jsdoc:html --targetDir=out/api
grunt screenshots --browserName=chrome
sphinx-build -b html doc/manual/de out/de/manual
}

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Skipping deploy;"
exit 0
fi

if [ "$SOURCE_BRANCH" != "master" ]; then
echo "ATTENTION! Deploying docs from non master branch. Please change this!!!"
fi


# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`

# Clone the existing gh-pages for this repo into out/
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone $REPO out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..

# Clean out existing contents
rm -rf out/**/* || exit 0

# Run our creation script
createDocs

# Now let's go have some fun with the cloned repo
cd out
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"

# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
if [ -z `git diff --exit-code` ]; then
echo "No changes to the output on this push; exiting."
exit 0
fi

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add --all .
git commit -m "Deploy to GitHub Pages: ${SHA}"

# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in ../.doc/deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key

# Now that we're all set up, we can push.
git push $SSH_REPO $TARGET_BRANCH
Binary file added .doc/deploy_key.enc
Binary file not shown.
15 changes: 15 additions & 0 deletions .doc/docutils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# copyright (c) 2010-2016, Christian Mayer and the CometVisu contributers.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Empty file.
99 changes: 99 additions & 0 deletions .doc/docutils/directives/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-

# copyright (c) 2010-2016, Christian Mayer and the CometVisu contributers.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

from docutils import statemachine
from docutils.parsers.rst import Directive
from os import path
from helper.schema import *
import gettext
gettext.install('messages', localedir='locale')

type_mapping = {
'boolean': "true %s false" % _('or'),
'string': _('string'),
'decimal': _('decimal')
}

schema = Schema(path.join("src", "visu_config.xsd"))


class BaseDirective(Directive):
locale = 'en'

def init_locale(self):
#locale = self.state_machine.document.settings.language_code
# this is a hack, but as language_code settings returns 'en' its the only known way to get the locale
self.locale = self.state_machine.document.settings._source.split(path.sep +"manual" + path.sep, 1)[1].split(path.sep)[0]
t = gettext.translation('messages', localedir='locale', languages=[self.locale])
t.install()


class BaseXsdDirective(BaseDirective):

def get_cell_data(self, content):
return 0, 0, 0, statemachine.StringList( content.splitlines())

def normalize_values(self, values):
if len(values) <= 1:
return (" %s " % _("or")).join(values)
else:
return " ".join([", ".join(values[0:-1]), _("or"), values[-1]])

def normalize_type(self, type):
if type[0:4] == "xsd:":
type = type[4:]
return type_mapping[type] if type in type_mapping else type

def generate_table(self, element_name):
table_body = []
for attr in schema.get_widget_attributes(element_name):
if 'name' in attr.attrib:
name = attr.get('name')
atype, values = schema.get_attribute_type(attr)
description = schema.get_node_documentation(attr, self.locale)
if description is not None:
description = description.text
else:
description = ''
elif 'ref' in attr.attrib:
name = attr.get('ref')
type_def = schema.get_attribute(name)
atype, values = schema.get_attribute_type(type_def)
description = schema.get_node_documentation(type_def, self.locale)
if description is not None:
description = description.text
else:
description = ''

if attr.get('use', 'optional') == "required":
name += "*"

atype = self.normalize_type(atype) if len(values) == 0 else self.normalize_values(values)
row = [self.get_cell_data(name), self.get_cell_data(atype), self.get_cell_data(description)]
table_body.append(row)

if len(table_body) == 0:
return None

table_head = [[self.get_cell_data(_('Name')), self.get_cell_data(_('Type')), self.get_cell_data(_('Description'))]]
table = ([20, 20, 60], table_head, table_body)

table_node = self.state.build_table(table, self.content_offset)
table_node['classes'] += self.options.get('class', [])

return table_node
73 changes: 73 additions & 0 deletions .doc/docutils/directives/elements_information.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-

# copyright (c) 2010-2016, Christian Mayer and the CometVisu contributers.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

from docutils import nodes
from docutils.parsers.rst import directives
from common import BaseXsdDirective, schema
import gettext
gettext.install('cv', localedir='locale')


class ElementsInformationDirective(BaseXsdDirective):
"""
reStructuredText directive for information about allowed child elements. Extracts information for the given element from
the visu_config.xsd file and adds it to the document.

..elements_information:: <element-name>

@author Tobias Bräutigam
@since 0.10.0
"""
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {}
has_content = False

def make_title(self, element):
if element.get("name", None) is not None:
name = element.get("name")
if element.get("minOccurs") is not None and int(element.get("minOccurs")) > 0:
name += "*"
text_nodes, messages = self.state.inline_text(name,
self.lineno)
title = nodes.title(name, '', *text_nodes)
else:
title = None
messages = []
return title, messages

def run(self):
self.init_locale()

element_name = self.arguments[0]
res_nodes = []

for element in schema.get_widget_elements(element_name):
title, messages = self.make_title(element)

table_node = self.generate_table(element.get("name"))
if table_node is not None:
if title is not None:
table_node.insert(0, title)

res_nodes.append(table_node)

return res_nodes

directives.register_directive("elements_information", ElementsInformationDirective)
Empty file.
Loading