forked from polimi-ispl/prnu-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (93 loc) · 3.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# FOLDERS
VENV := venv
PROJECT_NAME := prnu
# PROGRAMS AND FLAGS
PYTHON := python3
PYFLAGS :=
PIP := pip
# ======= DOC =========
AUTHORS := --author "Luca Bondi, Paolo Bestagini, Nicolò Bonettini, Simone Alghisi, Samuele Bortolotti, Massimo Rizzoli"
VERSION :=-r 2.0.0
LANGUAGE := --language en
SPHINX_EXTENSIONS := --extensions sphinx.ext.autodoc --extensions sphinx.ext.viewcode
DOC_FOLDER := docs
## Quickstart
SPHINX_QUICKSTART := sphinx-quickstart
SPHINX_QUICKSTART_FLAGS := --sep --no-batchfile --project ffdnet $(AUTHORS) $(VERSION) $(LANGUAGE) $(SPHINX_EXTENSIONS)
# Build
BUILDER := html
SPHINX_BUILD := make $(BUILDER)
SPHINX_API_DOC := sphinx-apidoc
SPHINX_API_DOC_FLAGS := -o $(DOC_FOLDER)/source .
SPHINX_THEME = sphinx_rtd_theme
DOC_INDEX := index.html
# INDEX.rst
define INDEX
.. ffdnet documentation master file, created by
sphinx-quickstart on Sat Nov 20 23:38:46 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. include:: ../../README.rst
.. toctree::
:maxdepth: 3
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
endef
export INDEX
# COLORS
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
NONE := \033[0m
# COMMANDS
ECHO := echo -e
MKDIR := mkdir -p
OPEN := xdg-open
SED := sed
# RULES
.PHONY: help env install install-dev open-doc doc doc-layout
help:
@$(ECHO) '$(YELLOW)Makefile help$(NONE)'
@$(ECHO) " \
* env : generates the virtual environment using venv\n \
* install : install the requirements listed in requirements.txt\n \
* install-dev : install the development requirements listed in requirements.dev.txt\n \
* doc-layout : generates the Sphinx documentation layout\n \
* doc : generates the documentation (requires an existing documentation layout)\n \
* open-doc : opens the documentation"
env:
@$(ECHO) '$(GREEN)Creating the virtual environment..$(NONE)'
@$(MKDIR) $(VENV)
@$(eval PYTHON_VERSION=$(shell $(PYTHON) --version | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | cut -f1,2 -d'.'))
@$(PYTHON_VERSION) -m venv $(VENV)/$(PROJECT_NAME)
@$(ECHO) '$(GREEN)Done$(NONE)'
install:
@$(ECHO) '$(GREEN)Installing requirements..$(NONE)'
@pip install -r requirements.txt
@$(ECHO) '$(GREEN)Done$(NONE)'
install-dev:
@$(ECHO) '$(GREEN)Installing requirements..$(NONE)'
@$(PIP) install -r requirements.dev.txt
@$(ECHO) '$(GREEN)Done$(NONE)'
doc-layout:
@$(ECHO) '$(BLUE)Generating the Sphinx layout..$(NONE)'
$(SPHINX_QUICKSTART) $(DOC_FOLDER) $(SPHINX_QUICKSTART_FLAGS)
@$(ECHO) "\nimport os\nimport sys\nsys.path.insert(0, os.path.abspath('../..'))" >> $(DOC_FOLDER)/source/conf.py
@$(ECHO) "$$INDEX" > $(DOC_FOLDER)/source/index.rst
@$(SED) -i -e "s/html_theme = 'alabaster'/html_theme = '$(SPHINX_THEME)'/g" $(DOC_FOLDER)/source/conf.py
@$(ECHO) '$(BLUE)Done$(NONE)'
doc:
@$(ECHO) '$(BLUE)Generating the documentation..$(NONE)'
$(SPHINX_API_DOC) $(SPHINX_API_DOC_FLAGS)
cd $(DOC_FOLDER); $(SPHINX_BUILD)
@$(ECHO) '$(BLUE)Done$(NONE)'
open-doc:
@$(ECHO) '$(BLUE)Open documentation..$(NONE)'
$(OPEN) $(DOC_FOLDER)/build/$(BUILDER)/$(DOC_INDEX)
@$(ECHO) '$(BLUE)Done$(NONE)'