mirror of
https://github.com/NaN-tic/trydoc.git
synced 2023-12-14 02:03:42 +01:00
Version 0.4: package provide scripts to bootstrap and mantain the sphinx project
This commit is contained in:
parent
b129880c12
commit
89734ccd57
|
@ -5,6 +5,7 @@ include CHANGELOG
|
|||
recursive-include sphinxcontrib
|
||||
recursive-include doc *.rst *.py Makefile
|
||||
recursive-include tests *.py
|
||||
recursive-include sphinxcontrib *.template
|
||||
prune doc/_build
|
||||
prune test/_build
|
||||
|
||||
|
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
path.py
|
||||
proteus
|
||||
Sphinx>=1.0b2
|
||||
sphinxcontrib-inheritance>=0.5
|
17
setup.py
17
setup.py
|
@ -6,11 +6,16 @@ with open('README') as stream:
|
|||
long_desc = stream.read()
|
||||
|
||||
|
||||
requires = ['Sphinx>=1.0b2']
|
||||
requires = [
|
||||
'path.py',
|
||||
'proteus',
|
||||
'Sphinx>=1.0b2',
|
||||
'sphinxcontrib-inheritance>=0.5',
|
||||
]
|
||||
|
||||
setup(
|
||||
name='trydoc',
|
||||
version='0.3',
|
||||
version='0.4',
|
||||
url='https://bitbucket.org/nantic/trydoc',
|
||||
download_url='http://pypi.python.org/pypi/trydoc',
|
||||
license='BSD',
|
||||
|
@ -33,7 +38,13 @@ setup(
|
|||
platforms='any',
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'trydoc-quickstart = sphinxcontrib.trydoc.quickstart:main',
|
||||
'trydoc-update-modules = sphinxcontrib.trydoc.update_modules:main',
|
||||
'trydoc-symlinks = sphinxcontrib.trydoc.symlinks:main',
|
||||
],
|
||||
},
|
||||
install_requires=requires,
|
||||
namespace_packages=['sphinxcontrib'],
|
||||
)
|
||||
|
||||
|
|
180
sphinxcontrib/trydoc/Makefile.template
Normal file
180
sphinxcontrib/trydoc/Makefile.template
Normal file
|
@ -0,0 +1,180 @@
|
|||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = %(rbuilddir)s
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error \
|
||||
The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx \
|
||||
installed, then set the SPHINXBUILD environment variable to point \
|
||||
to the full path of the '$(SPHINXBUILD)' executable. Alternatively you \
|
||||
can add the directory with the executable to your PATH. \
|
||||
If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) \
|
||||
$(SPHINXOPTS) %(rsrcdir)s
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) %(rsrcdir)s
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \
|
||||
latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation \
|
||||
(if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \\
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \\
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/%(project_fn)s.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/%(project_fn)s.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/%(project_fn)s"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp\
|
||||
$$HOME/.local/share/devhelp/%(project_fn)s"
|
||||
@echo "# devhelp"
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \\`make' in that directory to run these through (pdf)latex" \\
|
||||
"(use \\`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \\`make' in that directory to run these through makeinfo" \\
|
||||
"(use \\`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \\
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \\
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
2
sphinxcontrib/trydoc.py → sphinxcontrib/trydoc/__init__.py
Executable file → Normal file
2
sphinxcontrib/trydoc.py → sphinxcontrib/trydoc/__init__.py
Executable file → Normal file
|
@ -19,7 +19,7 @@ import sys
|
|||
import tempfile
|
||||
import proteus
|
||||
|
||||
import tryton
|
||||
#import tryton
|
||||
import gtk
|
||||
import gobject
|
||||
|
274
sphinxcontrib/trydoc/conf.py.template
Normal file
274
sphinxcontrib/trydoc/conf.py.template
Normal file
|
@ -0,0 +1,274 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# %(project)s documentation build configuration file, created by
|
||||
# sphinx-quickstart on %(now)s.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
import ConfigParser
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [%(extensions)s]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['%(dot)stemplates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '%(suffix)s'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = '%(master_str)s'
|
||||
|
||||
# General information about the project.
|
||||
project = u'%(project_str)s'
|
||||
copyright = u'%(copyright_str)s'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '%(version_str)s'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '%(release_str)s'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%%B %%d, %%Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = [%(exclude_patterns)s]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
|
||||
# -- Configuration of inheritance ---------------------------------------------
|
||||
|
||||
inheritance_autoreferences = False
|
||||
inheritance_debug = %(inheritance_debug)s
|
||||
verbose = %(verbose)s
|
||||
|
||||
# Load modules from configuration File
|
||||
config = ConfigParser.ConfigParser()
|
||||
f = open('modules.cfg', 'r')
|
||||
config.readfp(f)
|
||||
f.close()
|
||||
|
||||
inheritance_modules = [
|
||||
'trytond_doc',
|
||||
]
|
||||
inheritance_modules += [ x for x,y in config.items('modules') if y=='True']
|
||||
|
||||
# -- Configuration of trydoc --------------------------------------------------
|
||||
|
||||
if 'sphinxcontrib.trydoc' in extensions:
|
||||
import proteus
|
||||
%(trytond_into_path)s
|
||||
proteus.config.set_trytond(%(set_trytond_params)s)
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['%(dot)sstatic']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%%b %%d, %%Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '%(project_fn)sdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('%(master_str)s', '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s',
|
||||
u'%(author_texescaped_str)s', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('%(master_str)s', '%(project_manpage)s', u'%(project_doc_str)s',
|
||||
[u'%(author_str)s'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('%(master_str)s', '%(project_fn)s', u'%(project_doc_str)s',
|
||||
u'%(author_str)s', '%(project_fn)s', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
22
sphinxcontrib/trydoc/index.rst.es.template
Normal file
22
sphinxcontrib/trydoc/index.rst.es.template
Normal file
|
@ -0,0 +1,22 @@
|
|||
Manual de usuario de Tryton
|
||||
===========================
|
||||
|
||||
Este documento contiene algunas directrices para la utilización de la
|
||||
aplicación Tryton. Esta documentación se genera a partir de los módulos que
|
||||
tengan **instalados y disponibles** en su servidor de Tryton. Por este motivo,
|
||||
la documentación es según estos módulos que dispone, pudiendose **ampliar** si
|
||||
dispone de otros módulos que amplien nuevas funcionalidades.
|
||||
|
||||
Contenidos:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
trytond_doc/base
|
||||
trytond_doc/maestros
|
||||
trytond_doc/areas_funcionales
|
||||
trytond_doc/admin
|
||||
trytond_doc/modules
|
||||
|
||||
* :ref:`search`
|
||||
|
509
sphinxcontrib/trydoc/quickstart.py
Normal file
509
sphinxcontrib/trydoc/quickstart.py
Normal file
|
@ -0,0 +1,509 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
sphinxcontrib.trydoc.quickstart
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Quickly setup Tryton documentation source to work with Sphinx.
|
||||
|
||||
:copyright: Copyright 2013 by the NaN·tic team, see AUTHORS.
|
||||
:license: GPL3, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from os import path
|
||||
from codecs import open
|
||||
|
||||
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
||||
|
||||
from sphinx import __version__
|
||||
from sphinx.util.osutil import make_filename
|
||||
from sphinx.util.console import (purple, bold, red, turquoise,
|
||||
nocolor, color_terminal)
|
||||
from sphinx.util import texescape
|
||||
|
||||
# function to get input from terminal -- overridden by the test suite
|
||||
try:
|
||||
# this raw_input is not converted by 2to3
|
||||
term_input = raw_input
|
||||
except NameError:
|
||||
term_input = input
|
||||
|
||||
|
||||
PROMPT_PREFIX = '> '
|
||||
SOURCES_DIR = path.dirname(__file__)
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
# prevents that the file is checked for being written in Python 2.x syntax
|
||||
QUICKSTART_CONF = '#!/usr/bin/env python3\n'
|
||||
else:
|
||||
QUICKSTART_CONF = ''
|
||||
|
||||
with open('%s/conf.py.template' % SOURCES_DIR) as template_file:
|
||||
QUICKSTART_CONF += template_file.read()
|
||||
|
||||
with open('%s/Makefile.template' % SOURCES_DIR) as template_file:
|
||||
MAKEFILE = template_file.read()
|
||||
|
||||
MODULESCFG_FILE = '''[modules]
|
||||
|
||||
'''
|
||||
|
||||
|
||||
def mkdir_p(dir):
|
||||
if path.isdir(dir):
|
||||
return
|
||||
os.makedirs(dir)
|
||||
|
||||
|
||||
class ValidationError(Exception):
|
||||
"""Raised for validation errors."""
|
||||
|
||||
|
||||
def is_path(x):
|
||||
if path.exists(x) and not path.isdir(x):
|
||||
raise ValidationError("Please enter a valid path name.")
|
||||
return x
|
||||
|
||||
|
||||
def nonempty(x):
|
||||
if not x:
|
||||
raise ValidationError("Please enter some text.")
|
||||
return x
|
||||
|
||||
|
||||
def choice(*l):
|
||||
def val(x):
|
||||
if x not in l:
|
||||
raise ValidationError('Please enter one of %s.' % ', '.join(l))
|
||||
return x
|
||||
return val
|
||||
|
||||
|
||||
def boolean(x):
|
||||
if x.upper() not in ('Y', 'YES', 'N', 'NO'):
|
||||
raise ValidationError("Please enter either 'y' or 'n'.")
|
||||
return x.upper() in ('Y', 'YES')
|
||||
|
||||
|
||||
def suffix(x):
|
||||
if not (x[0:1] == '.' and len(x) > 1):
|
||||
raise ValidationError("Please enter a file suffix, "
|
||||
"e.g. '.rst' or '.txt'.")
|
||||
return x
|
||||
|
||||
|
||||
def ok(x):
|
||||
return x
|
||||
|
||||
|
||||
def do_prompt(d, key, text, default=None, validator=nonempty):
|
||||
while True:
|
||||
if default:
|
||||
prompt = purple(PROMPT_PREFIX + '%s [%s]: ' % (text, default))
|
||||
else:
|
||||
prompt = purple(PROMPT_PREFIX + text + ': ')
|
||||
x = term_input(prompt)
|
||||
if default and not x:
|
||||
x = default
|
||||
if not isinstance(x, unicode):
|
||||
# for Python 2.x, try to get a Unicode string out of it
|
||||
if x.decode('ascii', 'replace').encode('ascii', 'replace') != x:
|
||||
if TERM_ENCODING:
|
||||
x = x.decode(TERM_ENCODING)
|
||||
else:
|
||||
print turquoise('* Note: non-ASCII characters entered '
|
||||
'and terminal encoding unknown -- '
|
||||
'assuming UTF-8 or Latin-1.')
|
||||
try:
|
||||
x = x.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
x = x.decode('latin1')
|
||||
try:
|
||||
x = validator(x)
|
||||
except ValidationError, err:
|
||||
print red('* ' + str(err))
|
||||
continue
|
||||
break
|
||||
d[key] = x
|
||||
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
# remove Unicode literal prefixes
|
||||
_unicode_string_re = re.compile(r"[uU]('.*?')")
|
||||
|
||||
def _convert_python_source(source):
|
||||
return _unicode_string_re.sub('\1', source)
|
||||
|
||||
globals()['QUICKSTART_CONF'] = _convert_python_source(
|
||||
globals()['QUICKSTART_CONF'])
|
||||
|
||||
del _unicode_string_re, _convert_python_source
|
||||
|
||||
|
||||
def ask_user(d):
|
||||
"""Ask the user for quickstart values missing from *d*.
|
||||
|
||||
Values are:
|
||||
|
||||
* lang: language code
|
||||
* path: root path
|
||||
* sep: separate source and build dirs (bool)
|
||||
* dot: replacement for dot in _templates etc.
|
||||
* project: project name
|
||||
* author: author names
|
||||
* version: version of project
|
||||
* release: release of project
|
||||
* suffix: source file suffix
|
||||
* inheritance_debug debug messages from inheritance extension on Makefile execution
|
||||
* verbose more verbose messages on Makefile execution
|
||||
* set_trytond_params parameters for preoteus.config.set_trytond() call
|
||||
* master: master document name
|
||||
* ext_*: extensions to use (bools)
|
||||
* makefile: make Makefile
|
||||
"""
|
||||
|
||||
print bold('Welcome to the Trydoc %s quickstart utility.') % __version__
|
||||
print '''
|
||||
Please enter values for the following settings (just press Enter to
|
||||
accept a default value, if one is given in brackets).'''
|
||||
|
||||
if 'lang' in d:
|
||||
print bold('''
|
||||
Selected language: %s''' % d['lang'])
|
||||
else:
|
||||
print '''
|
||||
Enter the language code for documentation.'''
|
||||
do_prompt(d, 'lang', 'Language code for the documentation', 'es',
|
||||
choice(['es']))
|
||||
while not path.isfile('%s/index.rst.%s.template'
|
||||
% (SOURCES_DIR, d['lang'])):
|
||||
print
|
||||
print bold('Error: do not exist a template of master file (index.rst) '
|
||||
'for the selected language.')
|
||||
do_prompt(d, 'lang', 'Language code for the documentation', 'es',
|
||||
choice('es'))
|
||||
if not d['lang']:
|
||||
sys.exit(1)
|
||||
|
||||
if 'path' in d:
|
||||
print bold('''
|
||||
Selected root path: %s''' % d['path'])
|
||||
else:
|
||||
print '''
|
||||
Enter the root path for documentation.'''
|
||||
do_prompt(d, 'path', 'Root path for the documentation', '.', is_path)
|
||||
|
||||
while path.isfile(path.join(d['path'], 'conf.py')) or \
|
||||
path.isfile(path.join(d['path'], 'source', 'conf.py')):
|
||||
print
|
||||
print bold('Error: an existing conf.py has been found in the '
|
||||
'selected root path.')
|
||||
print 'trydoc-quickstart will not overwrite existing Sphinx projects.'
|
||||
print
|
||||
do_prompt(d, 'path', 'Please enter a new root path (or just Enter '
|
||||
'to exit)', '', is_path)
|
||||
if not d['path']:
|
||||
sys.exit(1)
|
||||
|
||||
if 'sep' not in d:
|
||||
print '''
|
||||
You have two options for placing the build directory for Sphinx output.
|
||||
Either, you use a directory "_build" within the root path, or you separate
|
||||
"source" and "build" directories within the root path.'''
|
||||
do_prompt(d, 'sep', 'Separate source and build directories (y/N)', 'n',
|
||||
boolean)
|
||||
|
||||
if 'dot' not in d:
|
||||
print '''
|
||||
Inside the root directory, two more directories will be created; "_templates"
|
||||
for custom HTML templates and "_static" for custom stylesheets and other static
|
||||
files. You can enter another prefix (such as ".") to replace the underscore.'''
|
||||
do_prompt(d, 'dot', 'Name prefix for templates and static dir', '_',
|
||||
ok)
|
||||
|
||||
if 'project' not in d:
|
||||
print '''
|
||||
The project name will occur in several places in the built documentation.'''
|
||||
do_prompt(d, 'project', 'Project name')
|
||||
if 'author' not in d:
|
||||
do_prompt(d, 'author', 'Author name(s)')
|
||||
|
||||
if 'version' not in d:
|
||||
print '''
|
||||
Sphinx has the notion of a "version" and a "release" for the
|
||||
software. Each version can have multiple releases. For example, for
|
||||
Python the version is something like 2.5 or 3.0, while the release is
|
||||
something like 2.5.1 or 3.0a1. If you don't need this dual structure,
|
||||
just set both to the same value.'''
|
||||
do_prompt(d, 'version', 'Project version', '1.0')
|
||||
if 'release' not in d:
|
||||
do_prompt(d, 'release', 'Project release', d['version'])
|
||||
|
||||
if 'suffix' not in d:
|
||||
print '''
|
||||
The file name suffix for source files. Commonly, this is either ".txt"
|
||||
or ".rst". Only files with this suffix are considered documents.'''
|
||||
do_prompt(d, 'suffix', 'Source file suffix', '.rst', suffix)
|
||||
|
||||
if 'master' not in d:
|
||||
print '''
|
||||
One document is special in that it is considered the top node of the
|
||||
"contents tree", that is, it is the root of the hierarchical structure
|
||||
of the documents. Normally, this is "index", but if your "index"
|
||||
document is a custom template, you can also set this to another filename.'''
|
||||
do_prompt(d, 'master', 'Name of your master document (without suffix)',
|
||||
'index')
|
||||
|
||||
while (path.isfile(path.join(d['path'], d['master'] + d['suffix'])) or
|
||||
path.isfile(path.join(d['path'], 'source',
|
||||
d['master'] + d['suffix']))):
|
||||
print
|
||||
print bold('Error: the master file %s has already been found in the '
|
||||
'selected root path.' % (d['master'] + d['suffix']))
|
||||
print 'trydoc-quickstart will not overwrite the existing file.'
|
||||
print
|
||||
do_prompt(d, 'master', 'Please enter a new file name, or rename the '
|
||||
'existing file and press Enter', d['master'])
|
||||
|
||||
# if 'ext_autodoc' not in d:
|
||||
# print '''
|
||||
#Please indicate if you want to use one of the following Sphinx extensions:'''
|
||||
# do_prompt(d, 'ext_autodoc', 'autodoc: automatically insert docstrings '
|
||||
# 'from modules (y/N)', 'n', boolean)
|
||||
# if 'ext_doctest' not in d:
|
||||
# do_prompt(d, 'ext_doctest', 'doctest: automatically test code '
|
||||
# 'snippets in doctest blocks (y/N)', 'n', boolean)
|
||||
# if 'ext_todo' not in d:
|
||||
# do_prompt(d, 'ext_todo', 'todo: write "todo" entries '
|
||||
# 'that can be shown or hidden on build (y/N)', 'n', boolean)
|
||||
# if 'ext_coverage' not in d:
|
||||
# do_prompt(d, 'ext_coverage', 'coverage: checks for documentation '
|
||||
# 'coverage (y/N)', 'n', boolean)
|
||||
# if 'ext_pngmath' not in d:
|
||||
# do_prompt(d, 'ext_pngmath', 'pngmath: include math, rendered '
|
||||
# 'as PNG images (y/N)', 'n', boolean)
|
||||
# if 'ext_mathjax' not in d:
|
||||
# do_prompt(d, 'ext_mathjax', 'mathjax: include math, rendered in the '
|
||||
# 'browser by MathJax (y/N)', 'n', boolean)
|
||||
# if d['ext_pngmath'] and d['ext_mathjax']:
|
||||
# print '''Note: pngmath and mathjax cannot be enabled at the same time.
|
||||
#pngmath has been deselected.'''
|
||||
# if 'ext_ifconfig' not in d:
|
||||
# do_prompt(d, 'ext_ifconfig', 'ifconfig: conditional inclusion of '
|
||||
# 'content based on config values (y/N)', 'n', boolean)
|
||||
# if 'ext_viewcode' not in d:
|
||||
# do_prompt(d, 'ext_viewcode', 'viewcode: include links to the source '
|
||||
# 'code of documented Python objects (y/N)', 'n', boolean)
|
||||
|
||||
if 'makefile' not in d:
|
||||
print '''
|
||||
A Makefile and a Windows command file can be generated for you so that you
|
||||
only have to run e.g. `make html' instead of invoking sphinx-build
|
||||
directly.'''
|
||||
do_prompt(d, 'makefile', 'Create Makefile? (Y/n)', 'y', boolean)
|
||||
print
|
||||
|
||||
if 'inheritance_debug' not in d:
|
||||
print '''
|
||||
Do you want more verbose messages from sphinxcontrib-inheritance extension when
|
||||
execute the Makefile? It is useful if you are developing it or you have any bug
|
||||
to report.'''
|
||||
do_prompt(d, 'inheritance_debug',
|
||||
'Enable sphinxcontrib-inheritance debug messages (y/N)', 'n',
|
||||
boolean)
|
||||
print
|
||||
|
||||
if 'verbose' not in d:
|
||||
print '''
|
||||
Do you want more verbose messages from sphinxcontrib-inheritance and trydoc
|
||||
extension when execute the Makefile? It is useful if you are developing them or
|
||||
you have any bug to report.'''
|
||||
do_prompt(d, 'verbose',
|
||||
'More verbose messages on Makefile execution (y/N)', 'n', boolean)
|
||||
print
|
||||
|
||||
if 'set_trytond_params' not in d:
|
||||
print '''
|
||||
A persistent database is recommended in production environment to get the field
|
||||
names, menus and other dynamic information exactly as the customers are
|
||||
viewing.
|
||||
If you choose No, a SQLite with the selected modules will be created each time
|
||||
to generate the manual.'''
|
||||
do_prompt(d, 'persistent',
|
||||
'Use a persistent database to generate the manual (Y/n)', 'y',
|
||||
boolean)
|
||||
if not d['persistent']:
|
||||
d['set_trytond_params'] = "database_type='sqlite'"
|
||||
else:
|
||||
print '''
|
||||
Write the database name of the customer for who is this manual to use it to
|
||||
generate the dynamic information as field names, menus...'''
|
||||
do_prompt(d, 'database', 'Database')
|
||||
print
|
||||
|
||||
print '''
|
||||
The admin password is required to connect to database.'''
|
||||
do_prompt(d, 'admin_password', 'Admin password')
|
||||
print
|
||||
|
||||
d['set_trytond_params'] = (
|
||||
"'%s', database_type='postgresql', password='%s'"
|
||||
% (d['database'], d['admin_password']))
|
||||
del d['database']
|
||||
del d['admin_password']
|
||||
d['persistent']
|
||||
|
||||
if 'trytond_installed' not in d:
|
||||
print '''
|
||||
If trytond is not installed as a Python module you must to provide the path to
|
||||
trytond directory to could be set into the system path.'''
|
||||
do_prompt(d, 'trytond_installed',
|
||||
'Is trytond installed as a Python module? (y/N)', 'n', boolean)
|
||||
if d['trytond_installed']:
|
||||
d['trytond_into_path'] = ''
|
||||
else:
|
||||
print '''
|
||||
Enter the root path for documentation.'''
|
||||
do_prompt(d, 'trytond_directory', 'Path to the trytond directory',
|
||||
'../trytond', is_path)
|
||||
print
|
||||
|
||||
d['trytond_directory'] = (
|
||||
path.relpath(d['trytond_directory'], d['path']))
|
||||
|
||||
d['trytond_into_path'] = '''sys.path.insert(0, '%s')
|
||||
''' % d['trytond_directory']
|
||||
del d['trytond_directory']
|
||||
del d['trytond_installed']
|
||||
|
||||
|
||||
def generate(d, overwrite=True, silent=False):
|
||||
"""Generate project based on values in *d*."""
|
||||
|
||||
texescape.init()
|
||||
|
||||
if 'mastertoctree' not in d:
|
||||
d['mastertoctree'] = ''
|
||||
if 'mastertocmaxdepth' not in d:
|
||||
d['mastertocmaxdepth'] = 2
|
||||
|
||||
d['project_fn'] = make_filename(d['project'])
|
||||
d['project_manpage'] = d['project_fn'].lower()
|
||||
d['now'] = time.asctime()
|
||||
d['project_underline'] = len(d['project']) * '='
|
||||
d['extensions'] = ', '.join(
|
||||
repr('sphinxcontrib.' + name) for name in ('inheritance', 'trydoc'))
|
||||
#d['extensions'] = ', '.join(
|
||||
# repr('sphinx.ext.' + name)
|
||||
# for name in ('autodoc', 'doctest', 'todo', 'coverage',
|
||||
# 'pngmath', 'mathjax', 'ifconfig', 'viewcode')
|
||||
# if d.get('ext_' + name))
|
||||
d['copyright'] = time.strftime('%Y') + ', ' + d['author']
|
||||
d['author_texescaped'] = unicode(d['author']).\
|
||||
translate(texescape.tex_escape_map)
|
||||
d['project_doc'] = d['project'] + ' Documentation'
|
||||
d['project_doc_texescaped'] = unicode(d['project'] + ' Documentation').\
|
||||
translate(texescape.tex_escape_map)
|
||||
|
||||
# escape backslashes and single quotes in strings that are put into
|
||||
# a Python string literal
|
||||
for key in ('project', 'project_doc', 'project_doc_texescaped',
|
||||
'author', 'author_texescaped', 'copyright',
|
||||
'version', 'release', 'master'):
|
||||
d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")
|
||||
|
||||
if not path.isdir(d['path']):
|
||||
mkdir_p(d['path'])
|
||||
|
||||
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']
|
||||
|
||||
mkdir_p(srcdir)
|
||||
if d['sep']:
|
||||
builddir = path.join(d['path'], 'build')
|
||||
d['exclude_patterns'] = ''
|
||||
else:
|
||||
builddir = path.join(srcdir, d['dot'] + 'build')
|
||||
d['exclude_patterns'] = repr(d['dot'] + 'build')
|
||||
mkdir_p(builddir)
|
||||
mkdir_p(path.join(srcdir, d['dot'] + 'templates'))
|
||||
mkdir_p(path.join(srcdir, d['dot'] + 'static'))
|
||||
|
||||
def write_file(fpath, mode, content):
|
||||
if overwrite or not path.isfile(fpath):
|
||||
print 'Creating file %s.' % fpath
|
||||
f = open(fpath, mode, encoding='utf-8')
|
||||
try:
|
||||
f.write(content)
|
||||
finally:
|
||||
f.close()
|
||||
else:
|
||||
print 'File %s already exists, skipping.' % fpath
|
||||
|
||||
conf_text = QUICKSTART_CONF % d
|
||||
|
||||
write_file(path.join(srcdir, 'conf.py'), 'w', conf_text)
|
||||
|
||||
with open('%s/index.rst.%s.template' % (SOURCES_DIR, d['lang'])
|
||||
) as template_file:
|
||||
MASTER_FILE = template_file.read()
|
||||
|
||||
masterfile = path.join(srcdir, d['master'] + d['suffix'])
|
||||
write_file(masterfile, 'w', MASTER_FILE % d)
|
||||
|
||||
modulescfgfile = path.join(srcdir, 'modules.cfg')
|
||||
write_file(modulescfgfile, 'w', MODULESCFG_FILE)
|
||||
|
||||
if d['makefile']:
|
||||
d['rsrcdir'] = d['sep'] and 'source' or '.'
|
||||
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
|
||||
# use binary mode, to avoid writing \r\n on Windows
|
||||
write_file(path.join(d['path'], 'Makefile'), 'wb', MAKEFILE % d)
|
||||
|
||||
if silent:
|
||||
return
|
||||
print
|
||||
print bold('Finished: An initial directory structure has been created.')
|
||||
print '''
|
||||
You should now populate the directory with symlinks to Tryton modules localized
|
||||
documentation.
|
||||
Use the trydoc-symlinks utility:
|
||||
trydoc-symlinks %s PATH_TO_modules_DIR %s
|
||||
trydoc-symlinks --no-remove %s PATH_TO_trytond_doc_DIR %s
|
||||
|
||||
After that, you can populate the modules.cfg file with the list of modules to
|
||||
include in the manual. It should be the installed modules in the customer's
|
||||
database.
|
||||
Use the trydoc-update-modules utility. Look the help:
|
||||
trydoc-update-modules --help
|
||||
|
||||
At the end, ''' % (d['lang'], d['path'], d['lang'], d['path']) + (d['makefile']
|
||||
and '''use the Makefile to build the docs, like so:
|
||||
make builder
|
||||
''' or '''use the sphinx-build command to build the docs, like so:
|
||||
sphinx-build -b builder %s %s
|
||||
''' % (srcdir, builddir)) + '''\
|
||||
where "builder" is one of the supported builders, e.g. html, latex or linkcheck.
|
||||
'''
|
||||
|
||||
|
||||
def main(argv=sys.argv):
|
||||
if not color_terminal():
|
||||
nocolor()
|
||||
|
||||
d = {}
|
||||
if len(argv) < 2 or len(argv) > 3:
|
||||
print 'Usage: trydoc-quickstart lang_code [root]'
|
||||
sys.exit(1)
|
||||
elif len(argv) == 3:
|
||||
d['path'] = argv[2]
|
||||
d['lang'] = argv[1]
|
||||
try:
|
||||
ask_user(d)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print
|
||||
print '[Interrupted.]'
|
||||
return
|
||||
generate(d)
|
106
sphinxcontrib/trydoc/symlinks.py
Normal file
106
sphinxcontrib/trydoc/symlinks.py
Normal file
|
@ -0,0 +1,106 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##############################################################################
|
||||
# Copyright (C) 2013 NaN·tic
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
##############################################################################
|
||||
import argparse
|
||||
import glob
|
||||
import sys
|
||||
from path import path
|
||||
from sphinx.util.console import bold, nocolor, color_terminal
|
||||
|
||||
from .quickstart import choice, do_prompt, is_path
|
||||
|
||||
# function to get input from terminal -- overridden by the test suite
|
||||
try:
|
||||
# this raw_input is not converted by 2to3
|
||||
term_input = raw_input
|
||||
except NameError:
|
||||
term_input = input
|
||||
|
||||
|
||||
def create_symlinks(modules_path, lang, root, remove=True):
|
||||
if remove:
|
||||
# Removing existing symlinks
|
||||
for root_file in path(root).listdir():
|
||||
if root_file.islink():
|
||||
print "removing %s" % root_file
|
||||
root_file.remove()
|
||||
|
||||
for module_doc_dir in glob.glob('%s/*/doc/%s' % (modules_path, lang)):
|
||||
print "symlink to %s" % module_doc_dir
|
||||
module_name = str(path(module_doc_dir).parent.parent.basename())
|
||||
symlink = path(root).joinpath(module_name)
|
||||
if not symlink.exists():
|
||||
path(root).relpathto(path(module_doc_dir)).symlink(symlink)
|
||||
|
||||
|
||||
def main(argv=sys.argv):
|
||||
if not color_terminal():
|
||||
nocolor()
|
||||
|
||||
d = {}
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('lang_code')
|
||||
parser.add_argument('modules_path')
|
||||
parser.add_argument('root', default='.')
|
||||
parser.add_argument('--no-remove', action='store_false', dest='remove',
|
||||
default=True, help='Do not remove existing symlinks in root')
|
||||
options = parser.parse_args()
|
||||
|
||||
d['lang'] = options.lang_code
|
||||
d['modules_path'] = options.modules_path
|
||||
d['path'] = options.root
|
||||
try:
|
||||
print bold('Welcome to the Trydoc symlinks creation utility.')
|
||||
print '''
|
||||
Please enter values for the following settings (just press Enter to
|
||||
accept a default value, if one is given in brackets).'''
|
||||
|
||||
if 'modules_path' in d:
|
||||
print bold('''
|
||||
Selected modules path: %s''' % d['modules_path'])
|
||||
else:
|
||||
print '''
|
||||
Enter the modules sources path where found the documentation.'''
|
||||
do_prompt(d, 'modules_path',
|
||||
'Modules sources path where found the documentation',
|
||||
'../trytond/trytond/modules', is_path)
|
||||
|
||||
if 'lang' in d:
|
||||
print bold('''
|
||||
Selected language: %s''' % d['lang'])
|
||||
else:
|
||||
print '''
|
||||
Enter the language code for documentation.'''
|
||||
do_prompt(d, 'lang', 'Language code for the documentation', 'es',
|
||||
choice(['es']))
|
||||
|
||||
if 'path' in d:
|
||||
print bold('''
|
||||
Selected root path: %s''' % d['path'])
|
||||
else:
|
||||
print '''
|
||||
Enter the root path for documentation.'''
|
||||
do_prompt(d, 'path', 'Root path of the documentation', '.',
|
||||
is_path)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print
|
||||
print '[Interrupted.]'
|
||||
return
|
||||
|
||||
create_symlinks(d['modules_path'], d['lang'], d['path'], options.remove)
|
71
sphinxcontrib/trydoc/update_modules.py
Normal file
71
sphinxcontrib/trydoc/update_modules.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##############################################################################
|
||||
# Copyright (C) 2013 NaN·tic
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
##############################################################################
|
||||
|
||||
import ConfigParser
|
||||
import argparse
|
||||
import sys
|
||||
import os.path
|
||||
from proteus import config as pconfig, Model
|
||||
|
||||
|
||||
def parse_arguments(arguments):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('database')
|
||||
parser.add_argument('--config-file', '-c', dest='config',
|
||||
default='modules.cfg',
|
||||
help='Config File to update modules (default: ./modules.cfg)')
|
||||
parser.add_argument('--trytond-dir', '-t', dest='trytond',
|
||||
help='Path to the trytond directory if it is not installed as a module')
|
||||
|
||||
settings = parser.parse_args()
|
||||
return settings
|
||||
|
||||
|
||||
def main(argv=sys.argv):
|
||||
options = parse_arguments(sys.argv)
|
||||
|
||||
if options.trytond:
|
||||
directory = os.path.abspath(os.path.normpath(options.trytond))
|
||||
if os.path.isdir(directory):
|
||||
sys.path.insert(0, directory)
|
||||
|
||||
pconfig.set_trytond(options.database, database_type='postgresql',
|
||||
password='admin')
|
||||
|
||||
Module = Model.get('ir.module.module')
|
||||
modules = Module.find([('state', '=', 'installed')])
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
f = open(options.config, 'rw')
|
||||
config.readfp(f)
|
||||
f.close()
|
||||
|
||||
modules = [module.name for module in modules]
|
||||
|
||||
op = config.options('modules')
|
||||
|
||||
for module in modules:
|
||||
if module in op:
|
||||
continue
|
||||
print module
|
||||
config.set('modules', module, True)
|
||||
|
||||
with open(options.config, 'wb') as configfile:
|
||||
config.write(configfile)
|
Loading…
Reference in a new issue