Skip to content
Snippets Groups Projects
Commit 05d7178d2f92 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

:books: also migrate documentation

parent 6b29f82d2045
No related branches found
No related tags found
No related merge requests found
.. _README:
Accounting periods
==================
......
......@@ -54,5 +54,6 @@
clean:
rm -rf $(BUILDDIR)/*
rm -f manifest
rm -f autotodo
.PHONY: html
......@@ -57,8 +58,8 @@
.PHONY: html
html: manifest
html: manifest autotodo
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
......@@ -60,11 +61,11 @@
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
.PHONY: dirhtml
dirhtml:
dirhtml: manifest autotodo
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
......@@ -66,9 +67,9 @@
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
.PHONY: singlehtml
singlehtml:
singlehtml: manifest autotodo
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
......@@ -86,9 +87,9 @@
@echo "Build finished; now you can process the JSON files."
.PHONY: htmlhelp
htmlhelp:
htmlhelp: manifest autotodo
$(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."
......@@ -90,37 +91,8 @@
$(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."
.PHONY: qthelp
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/AccountingPeriods.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/AccountingPeriods.qhc"
.PHONY: applehelp
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
.PHONY: devhelp
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/AccountingPeriods"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/AccountingPeriods"
@echo "# devhelp"
.PHONY: epub
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
......@@ -219,4 +191,7 @@
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
autotodo: autotodo.py
@./autotodo.py ../ .py TODO,FIXME,XXX
manifest: ../__manifest__.py manifest.py
......@@ -222,2 +197,3 @@
manifest: ../__manifest__.py manifest.py
@python manifest.py
@./manifest.py
====
TODO
====
.. todolist::
.. include:: autotodo
#!/usr/bin/env python3
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2014, 2018 XCG Consulting
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import os
import os.path
import sys
def main():
if len(sys.argv) != 4:
print("usage: autotodo.py <folder> <exts> <tags>")
sys.exit(1)
folder = sys.argv[1]
exts = sys.argv[2].split(',')
tags = sys.argv[3].split(',')
todolist = {tag: [] for tag in tags}
for root, dirs, files in os.walk(folder):
scan_folder((exts, tags, todolist), root, files)
create_autotodo(folder, todolist)
def write_info(f, infos, folder):
# Check sphinx version for lineno-start support
import sphinx
if sphinx.version_info < (1, 3):
lineno_start = False
else:
lineno_start = True
for i in infos:
path = i[0]
line = i[1]
lines = (line - 3, line + 4)
class_name = (
":class:`%s`" %
os.path.basename(os.path.splitext(path)[0])
)
f.write(
"%s\n"
"%s\n\n"
"Line %s\n"
"\t.. literalinclude:: %s\n"
"\t\t:language: python\n"
"\t\t:lines: %s-%s\n"
"\t\t:emphasize-lines: %s\n"
%
(
class_name,
"-" * len(class_name),
line,
path,
lines[0], lines[1],
line,
)
)
if lineno_start:
f.write("\t\t:lineno-start: %s\n" % lines[0])
f.write("\n")
def create_autotodo(folder, todolist):
with open('autotodo', 'w+') as f:
for tag, info in list(todolist.items()):
f.write("%s\n%s\n\n" % (tag, '=' * len(tag)))
write_info(f, info, folder)
def scan_folder(data_tuple, dirname, names):
(exts, tags, res) = data_tuple
file_info = {}
for name in names:
(root, ext) = os.path.splitext(name)
if ext in exts:
file_info = scan_file(os.path.join(dirname, name), tags)
for tag, info in list(file_info.items()):
if info:
res[tag].extend(info)
def scan_file(filename, tags):
res = {tag: [] for tag in tags}
with open(filename, 'r') as f:
for line_num, line in enumerate(f):
for tag in tags:
if tag in line:
res[tag].append((filename, line_num, line[:-1].strip()))
return res
if __name__ == "__main__":
main()
# -*- coding: utf-8 -*-
# flake8: noqa
#
# Accounting periods documentation build configuration file, created by
# sphinx-quickstart on Mon Apr 30 16:15:00 2018.
#
......@@ -39,7 +36,8 @@
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.graphviz',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinxodoo.ext.autodoc',
]
......@@ -57,11 +55,6 @@
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'Accounting periods'
copyright = '2018, XCG Consulting'
author = 'XCG Consulting'
# 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.
......@@ -74,6 +67,14 @@
# The short X.Y version.
version = '.'.join(release.split('.')[:4])
# General information about the project.
project = d['name']
copyright = u'2018, XCG Consulting'
author = d['author']
module_nospace = project.replace(" ", "")
module_description = d.get('summary', "")
module_lowercase = module_nospace.lower()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
......@@ -215,7 +216,7 @@
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = 'AccountingPeriodsDoc'
htmlhelp_basename = '%sdoc' % module_nospace
# -- Options for LaTeX output ---------------------------------------------
......@@ -237,9 +238,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'AccountingPeriods.tex',
'Accounting periods documentation',
'XCG Consulting', 'manual'),
(master_doc, '%s.tex' % module_nospace, u'%s Documentation' % project,
author, 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
......@@ -268,8 +268,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'AccountingPeriods',
'Accounting periods documentation',
(master_doc, module_lowercase, u'%s Documentation' % project,
[author], 1)
]
......@@ -284,7 +283,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AccountingPeriods',
'Accounting periods documentation',
u'Accounting periods documentation',
author, 'AccountingPeriods', '''
Accounting periods
''',
......@@ -306,10 +305,10 @@
todo_include_todos = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'https://docs.python.org/3/': None}
#
# odoo-sphinx-autodoc
#
......@@ -310,10 +309,12 @@
#
# odoo-sphinx-autodoc
#
# sphinxodoo_addons : List of addons name to load (if empty, no addon will be loaded)
this_module = os.path.basename(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sphinxodoo_addons = [this_module]
# sphinxodoo_addons: List of addons name to load (if empty, no addon will be
# loaded)
this_module = os.path.basename(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sphinxodoo_addons = [this_module, ]
# sphinxodoo_root_path : Path of the Odoo root directory
......@@ -319,3 +320,4 @@
# sphinxodoo_root_path : Path of the Odoo root directory
sphinxodoo_root_path = os.path.dirname(os.path.dirname(os.path.abspath(odoo.__file__)))
sphinxodoo_root_path = os.path.dirname(os.path.dirname(os.path.abspath(
odoo.__file__)))
# sphinxodoo_addons_path : List of paths were Odoo addons to load are located
......@@ -321,4 +323,5 @@
# sphinxodoo_addons_path : List of paths were Odoo addons to load are located
superproject_path = os.path.dirname(os.path.dirname(os.path.dirname(os.getenv('PWD'))))
c = configparser.ConfigParser()
superproject_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.getenv('PWD'))))
c = configparser.SafeConfigParser()
c.read(os.path.join(superproject_path, 'setup.cfg'))
......@@ -324,3 +327,3 @@
c.read(os.path.join(superproject_path, 'setup.cfg'))
sphinxodoo_addons_path = [os.path.join(sphinxodoo_root_path, 'addons')]
sphinxodoo_addons_path = []
......@@ -326,3 +329,3 @@
for line in c.get('odoo_scripts', 'addon_dirs', '').splitlines():
for line in c.get('odoo_scripts', 'addon_dirs').splitlines():
sphinxodoo_addons_path.append(os.path.join(superproject_path, line))
Welcome to this addon's documentation!
======================================
.. include:: manifest
Contents:
......@@ -9,7 +6,9 @@
:maxdepth: 2
README
modules
NEWS
TODO
Indices and tables
==================
......
#!/usr/bin/env python
#!/usr/bin/env python3
###############################################################################
#
# OpenERP, Open Source Management Solution
......@@ -2,7 +2,7 @@
###############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2016 XCG Consulting (http://www.xcg-consulting.fr/)
# Copyright (C) 2016, 2018 XCG Consulting (http://www.xcg-consulting.fr/)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
......@@ -18,7 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import ast
import os
from odoo.modules import load_information_from_description_file
def main():
......@@ -22,7 +24,7 @@
def main():
with open('../__manifest__.py', 'r') as f:
read_data = f.read()
d = ast.literal_eval(read_data)
module = os.path.basename(os.path.dirname(os.path.dirname(
os.path.realpath(__file__))))
d = load_information_from_description_file(module)
with open('manifest', 'w') as out:
......@@ -28,5 +30,9 @@
with open('manifest', 'w') as out:
out.write(d['description'])
manifest_content = (
d['description']
if 'description' in d
else d['summary'] if 'summary' in d else '')
out.write(manifest_content)
if __name__ == "__main__":
......
sphinx
git+https://github.com/OCA/odoo-sphinx-autodoc#egg=odoo-sphinx-autodoc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment