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
31 changed files
with
623 additions
and
179 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/python | ||
# -*- 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 |
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,31 @@ | ||
#!/usr/bin/python | ||
# -*- 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 | ||
import os | ||
import ConfigParser | ||
|
||
|
||
class Command(object): | ||
|
||
def __init__(self): | ||
self.config = ConfigParser.ConfigParser() | ||
self.config.read(os.path.join('.doc', 'config.ini')) | ||
self.root_dir = os.path.abspath(os.path.join(os.path.realpath(os.path.dirname(__file__)), '..', '..')) | ||
|
||
def process_output(self, line): | ||
print(line.rstrip()) |
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,103 @@ | ||
#!/usr/bin/python | ||
# -*- 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 | ||
|
||
import os | ||
import logging | ||
import sh | ||
import shutil | ||
from argparse import ArgumentParser | ||
from . import Command | ||
|
||
|
||
class DocGenerator(Command): | ||
|
||
def __init__(self): | ||
super(DocGenerator, self).__init__() | ||
self.log = logging.getLogger("doc") | ||
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') | ||
|
||
def _run(self, language, target_dir, browser, skip_screenshots=True, force=False): | ||
|
||
sphinx_build = sh.Command("sphinx-build") | ||
|
||
# check if sources exist for this language | ||
section = "manual-%s" % language | ||
target_type = self.config.get(section, "target-type") | ||
|
||
source_dir = os.path.join(self.root_dir, self.config.get(section, "source")) | ||
if target_dir is None: | ||
target_dir = os.path.join(self.root_dir, self.config.get(section, "target")) | ||
else: | ||
target_dir = os.path.join(self.root_dir, target_dir) | ||
|
||
if not os.path.exists(source_dir): | ||
self.log.error("no sources found for manual (%s) in language '%s'" % (source_dir, language)) | ||
exit(1) | ||
|
||
if force and os.path.exists(target_dir): | ||
# delete target dir | ||
print("deleting old content in '%s'" % target_dir) | ||
shutil.rmtree(target_dir) | ||
|
||
if not os.path.exists(target_dir): | ||
os.makedirs(target_dir) | ||
|
||
# first run generates the widget-example configs | ||
sphinx_build("-b", target_type, source_dir, target_dir, _out=self.process_output, _err=self.process_output) | ||
|
||
if not skip_screenshots: | ||
grunt = sh.Command("grunt") | ||
# generate the screenshots | ||
grunt("screenshots", "--subDir=manual", "--browserName=%s" % browser, _out=self.process_output, _err=self.process_output) | ||
|
||
# 2dn run with access to the generated screenshots | ||
sphinx_build("-b", target_type, source_dir, target_dir, _out=self.process_output, _err=self.process_output) | ||
|
||
def run(self, args): | ||
parser = ArgumentParser(usage="%(prog)s - CometVisu documentation generator") | ||
|
||
parser.add_argument("--force", "-f", dest="force", action='store_true', help="force existing docs to be overridden") | ||
|
||
parser.add_argument("--complete", "-c", dest="complete", action='store_true', help="Complete run: generate docs + screenshots") | ||
|
||
parser.add_argument("--language", "-l", dest="language", default="de", | ||
help="Language of documentation (only available for manual)") | ||
|
||
parser.add_argument("--target", dest="target", | ||
help="Target dir for generation") | ||
|
||
parser.add_argument("--browser", "-b", dest="browser", default="chrome", | ||
help="Browser used for screenshot generation") | ||
|
||
parser.add_argument('--doc-type', "-dt", dest="doc", default="manual", | ||
type=str, help='type of documentation to generate (manual, source)', nargs='?') | ||
|
||
options = parser.parse_args(args) | ||
|
||
if 'doc' not in options or options.doc == "manual": | ||
self._run(options.language, options.target, options.browser, force=options.force, skip_screenshots=not options.complete) | ||
elif options.doc == "source": | ||
grunt = sh.Command("grunt") | ||
if options.target is not None: | ||
grunt("api-doc", "--subDir=jsdoc", "--browserName=%s" % options.browser, "--targetDir=%s" % options.target, _out=self.process_output, _err=self.process_output) | ||
else: | ||
grunt("api-doc", "--subDir=jsdoc", "--browserName=%s" % options.browser, _out=self.process_output, _err=self.process_output) | ||
else: | ||
self.log.error("generation of '%s' documentation is not available" % options.type) | ||
exit(1) |
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,97 @@ | ||
#!/usr/bin/python | ||
# -*- 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 | ||
|
||
import os | ||
import logging | ||
from argparse import ArgumentParser | ||
from . import Command | ||
|
||
|
||
class Scaffolder(Command): | ||
|
||
def __init__(self): | ||
super(Scaffolder, self).__init__() | ||
self.log = logging.getLogger("scaffolder") | ||
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') | ||
|
||
def _run(self, language, widget_name, force=False): | ||
section = "manual-%s" % language | ||
template = os.path.join(self.root_dir, self.config.get(section, "widget-template")) | ||
if not os.path.exists(template): | ||
self.log.error("widget template '%s' language '%s' not found" % (widget_name,language)) | ||
exit(1) | ||
|
||
widgets = [] | ||
for file in os.listdir(os.path.join("src", "structure", "pure")): | ||
if file.endswith(".js") and not file.startswith("_"): | ||
# this is a widget | ||
found_widget = os.path.splitext(file)[0] | ||
if widget_name == "ALL" or widget_name.lower() == found_widget.lower(): | ||
widgets.append(found_widget) | ||
|
||
if len(widgets) == 0: | ||
self.log.error("widget '%s' does not exist" % widget_name) | ||
exit(1) | ||
|
||
if len(widgets) > 1: | ||
# do not allow forced overriding of multiple widgets, too dangerous | ||
force = False | ||
|
||
for widget_name in widgets: | ||
print("Generating doc source for '%s' widget in language '%s'" % (widget_name, language)) | ||
target = os.path.join(self.root_dir, self.config.get(section, "widgets"), widget_name.lower(), "index.rst") | ||
|
||
if force is False and os.path.exists(target): | ||
self.log.error("widget documentation already exists for widget '%s' in language '%s'" % (widget_name, language)) | ||
continue | ||
|
||
headline = "Das %s Widget" % widget_name | ||
headline_mark = "=" * len(headline) | ||
headline += "\n%s" % headline_mark | ||
|
||
with open(template, "r") as f: | ||
source = f.read() | ||
source = source.replace("%%%HEADLINE%%%", headline) | ||
source = source.replace("%%%WIDGET_NAME%%%", widget_name) | ||
source = source.replace("%%%WIDGET_NAME_LOWER%%%", widget_name.lower()) | ||
|
||
if not os.path.exists(target): | ||
os.makedirs(os.path.dirname(target)) | ||
|
||
with open(target, "w") as ft: | ||
ft.write(source) | ||
|
||
def run(self, args): | ||
parser = ArgumentParser(usage="%(prog)s - CometVisu documentation scaffolder") | ||
|
||
parser.add_argument("--force", "-f", dest="force", action='store_true', help="force existing docs to be overridden") | ||
|
||
parser.add_argument("--language", "-l", dest="language", default="de", | ||
help="Language the widget docs should be generated for") | ||
|
||
parser.add_argument("--widget", "-w", dest="widget", | ||
help="Name of the widget to generate docs for") | ||
|
||
options = parser.parse_args(args) | ||
|
||
if 'widget' not in options: | ||
self.log.error("please provide a widget name" % options.type) | ||
exit(1) | ||
|
||
self._run(options.language, options.widget, force=options.force) |
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,37 @@ | ||
#!/usr/bin/python | ||
# -*- 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 | ||
|
||
import logging | ||
import sh | ||
from . import Command | ||
|
||
class TranslationHandler(Command): | ||
|
||
def __init__(self): | ||
super(TranslationHandler, self).__init__() | ||
self.log = logging.getLogger("doc") | ||
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') | ||
|
||
def _run(self): | ||
pygettext = sh.Command("pygettext") | ||
pygettext("-d", "messages", "-p", self.config.get("main", "locale"), ".doc/docutils/directives/*.py", | ||
_out=self.process_output, _err=self.process_output) | ||
|
||
def run(self): | ||
self._run() |
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,18 @@ | ||
#!/usr/bin/python | ||
# -*- 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 |
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,18 @@ | ||
#!/usr/bin/python | ||
# -*- 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 |
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
Oops, something went wrong.