Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo scripts
Commits
6add84c9
Commit
6add84c9
authored
2 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
docker_build_doc
parent
7b91ef3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!144
✨ docker_build_doc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
NEWS.rst
+5
-0
5 additions, 0 deletions
NEWS.rst
README.rst
+7
-0
7 additions, 0 deletions
README.rst
odoo_scripts/docker_build_doc.py
+56
-60
56 additions, 60 deletions
odoo_scripts/docker_build_doc.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
69 additions
and
60 deletions
NEWS.rst
+
5
−
0
View file @
6add84c9
...
...
@@ -2,6 +2,11 @@
History
=======
16.10.0
-------
docker_doc_build: new command to build module documentation.
16.9.1
------
...
...
This diff is collapsed.
Click to expand it.
README.rst
+
7
−
0
View file @
6add84c9
...
...
@@ -32,6 +32,13 @@
This is part of the docker section.
docker_build_doc
----------------
Build documentation in docker. It runs `make html` so could potentially be used to do something else.
This is part of the docker section.
docker_isort
------------
...
...
This diff is collapsed.
Click to expand it.
odoo_scripts/docker_
flake8
.py
→
odoo_scripts/docker_
build_doc
.py
+
56
−
60
View file @
6add84c9
#!/usr/bin/env python3
# vim: set shiftwidth=4 softtabstop=4:
"""
Run flake8 in a docker
"""
Build documentation in a docker
"""
import
argparse
import
logging
import
os
import
sys
...
...
@@ -4,8 +3,9 @@
"""
import
argparse
import
logging
import
os
import
sys
from
.config
import
ODOO_15
,
Config
from
.config
import
Config
from
.docker_build
import
add_build_options
,
build_local_image
,
get_build_options
from
.docker_client
import
DockerClient
...
...
@@ -11,3 +11,4 @@
from
.docker_client
import
DockerClient
from
.docker_prettier
import
get_volumes
from
.parsing
import
apply
,
basic_parser
...
...
@@ -12,8 +13,8 @@
from
.parsing
import
apply
,
basic_parser
__version__
=
"
1.
2
.0
"
__date__
=
"
202
0-09
-10
"
__updated__
=
"
2022-
0
1-
27
"
__version__
=
"
1.
0
.0
"
__date__
=
"
202
2-11
-10
"
__updated__
=
"
2022-
1
1-
10
"
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -17,6 +18,8 @@
_logger
=
logging
.
getLogger
(
__name__
)
_DIR_DEST
=
"
build_doc_dir
"
def
__parser
():
program_version
=
__version__
...
...
@@ -29,7 +32,7 @@
program_license
=
"""
%s
Created by Vincent Hatakeyama on %s.
Copyright
2020,
2022 XCG Consulting. All rights reserved.
Copyright 2022 XCG Consulting. All rights reserved.
Licensed under the MIT License
...
...
@@ -45,23 +48,13 @@
return
parser
def
parser_add_flake8_group
(
parser
:
argparse
.
ArgumentParser
):
"""
Add flake8 option (--flake8/--no-flake8) to the given parser.
Defaults to not running flake8.
"""
flake8_group
=
parser
.
add_mutually_exclusive_group
()
flake8_group
.
add_argument
(
"
--flake8
"
,
help
=
"
Run flake8
"
,
action
=
"
store_true
"
,
dest
=
"
flake8
"
,
default
=
False
,
)
flake8_group
.
add_argument
(
"
--no-flake8
"
,
help
=
"
Do not run flake8 [default]
"
,
action
=
"
store_false
"
,
dest
=
"
flake8
"
,
default
=
False
,
def
parser_add_builddoc
(
parser
:
argparse
.
ArgumentParser
):
"""
Add isort option (--isort/--no-isort) to the given parser.
Defaults to not using isort.
"""
parser
.
add_argument
(
help
=
"
Create documentation on given directory (relative path, for example
"
"
github.com/OCA/server-auth)
"
,
dest
=
_DIR_DEST
,
)
...
...
@@ -65,12 +58,42 @@
)
def
apply_flake8
(
namespace
:
argparse
.
Namespace
,
odoo_type
:
str
):
"""
Run flake8 if the option was set.
"""
if
namespace
.
flake8
:
flake8
(
odoo_type
)
def
apply_build_doc
(
namespace
:
argparse
.
Namespace
,
config
:
Config
=
None
):
"""
Run isort if the option was set.
"""
if
_DIR_DEST
in
namespace
:
return
build_doc
(
directory
=
getattr
(
namespace
,
_DIR_DEST
),
config
=
config
,
)
return
0
def
build_doc
(
directory
:
str
=
""
,
config
:
Config
=
None
):
"""
Run isort
"""
if
config
is
None
:
config
=
Config
()
# determine image to use based on odoo version
repository
=
config
.
local_image
tag
=
config
.
local_tag
pwd
=
os
.
environ
[
"
PWD
"
]
volumes
,
path
=
get_volumes
(
pwd
,
directory
,
write
=
True
)
_logger
.
info
(
"
Building documentation in %s
"
,
path
)
return
DockerClient
.
run
(
repository
,
tag
,
{
"
entrypoint
"
:
"
make
"
,
"
user
"
:
os
.
getuid
(),
"
command
"
:
[
"
html
"
],
"
volumes
"
:
volumes
,
"
working_dir
"
:
path
,
},
False
,
)
def
main
(
argv
=
None
):
"""
Copy modules for a build, callable version that parses arguments
"""
parser
=
__parser
()
...
...
@@ -72,6 +95,8 @@
def
main
(
argv
=
None
):
"""
Copy modules for a build, callable version that parses arguments
"""
parser
=
__parser
()
add_build_options
(
parser
)
parser_add_builddoc
(
parser
)
nmspc
=
parser
.
parse_args
(
argv
)
...
...
@@ -77,3 +102,2 @@
nmspc
=
parser
.
parse_args
(
argv
)
apply
(
nmspc
)
config
=
Config
()
...
...
@@ -79,35 +103,7 @@
config
=
Config
()
odoo_type
=
config
.
odoo_type
return
flake8
(
odoo_type
)
def
flake8
(
odoo_type
:
str
,
pull
:
bool
=
True
):
"""
Run flake8
"""
# determine image to use based on odoo version
repository
=
"
quay.orus.io/odoo/odoo
"
if
odoo_type
in
(
"
odoo7
"
,
"
odoo8
"
,
"
odoo9
"
,
"
odoo10
"
):
repository
=
"
xcgd/flake8
"
tag
=
"
2
"
elif
odoo_type
==
ODOO_15
:
tag
=
"
15.0
"
else
:
repository
=
"
xcgd/flake8
"
tag
=
"
3
"
_logger
.
info
(
"
Running flake8
"
)
pwd
=
os
.
environ
[
"
PWD
"
]
return
DockerClient
.
run
(
repository
,
tag
,
{
"
entrypoint
"
:
"
flake8
"
,
"
command
"
:
[
"
/mnt
"
],
"
volumes
"
:
{
pwd
:
{
"
bind
"
:
"
/mnt
"
,
"
mode
"
:
"
ro
"
}},
"
working_dir
"
:
"
/mnt
"
,
},
pull
,
{
"
/mnt
"
:
pwd
},
)
apply
(
nmspc
)
build_local_image
(
get_build_options
(
nmspc
))
return
apply_build_doc
(
nmspc
,
config
=
config
)
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
6add84c9
...
...
@@ -45,6 +45,7 @@
"
do_tests=odoo_scripts.do_tests:main
"
,
"
docker_black=odoo_scripts.docker_black:main [docker]
"
,
"
docker_build=odoo_scripts.docker_build:main [docker]
"
,
"
docker_build_doc=odoo_scripts.docker_build_doc:main [docker]
"
,
"
docker_build_clean=odoo_scripts.docker_build_clean:main
"
,
"
docker_build_copy=odoo_scripts.docker_build_copy:main
"
,
"
docker_flake8=odoo_scripts.docker_flake8:main [docker]
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment