Homogénéisation de la procédure

This commit is contained in:
Benjamin Bohard 2020-09-07 16:15:55 +02:00
parent 95277a2891
commit 3d9fb7b622
4 changed files with 351 additions and 27 deletions

View File

@ -0,0 +1,203 @@
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
%\usepackage{microtype}
%\usepackage{xunicode}
\usepackage{polyglossia}
\usepackage{xltxtra}
\setdefaultlanguage{french}
\setotherlanguage{english}
\defaultfontfeatures{Mapping=tex-text} % To support LaTeX quoting style
%\setmainfont{Caviar Dreams}
\newfontfamily\headingfont[]{Caviar Dreams}
\usepackage{titlesec}
\defaultfontfeatures{Ligatures=TeX}
% Set sans serif font to Calibri
\setsansfont{LiberationSans}
% Set serifed font to Cambria
\setmainfont{LiberationSans}
\else
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsfonts}
\usepackage[english, francais]{babel}
\fi
\usepackage{pifont}
\usepackage{geometry}
\usepackage{fancybox}
\usepackage{verbatim}
\usepackage{eurosym}
%\usepackage{color}
\usepackage[svgnames,table]{xcolor}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{lastpage}
%\usepackage{enumitem}
\usepackage{makeidx}
\usepackage{tocbibind}
\usepackage[backend=biber,hyperref=true,backref=true]{biblatex}
\addbibresource{biblio.bib}
\usepackage{url}
\renewcommand{\baselinestretch}{1.3}
\addto\captionsfrench{\renewcommand{\contentsname}{Sommaire}}
\usepackage{graphicx}
\usepackage{pdfpages}
\makeindex
%
% Tableaux
%
\usepackage{array}
\usepackage{booktabs}
\usepackage{colortbl}
% Default
\newcolumntype{1}{l}
\newcolumntype{2}{l}
\newcolumntype{3}{l}
\newcolumntype{4}{l}
\newcolumntype{5}{l}
\newcolumntype{6}{l}
\newcolumntype{7}{l}
\newcolumntype{8}{l}
\newcommand*\heading{}
\newcommand*\beforeheading{}
\newcommand*\afterheading{}
\newcommand*\normalline{}
\newcommand*\lastline{}
%\renewcommand*\toprule{\arrayrulecolor{red}{\hline}}
% Nice looking rules, centered cells
\newcolumntype{1}{c}
\newcolumntype{2}{c}
\newcolumntype{3}{c}
\newcolumntype{4}{c}
\newcolumntype{5}{c}
\newcolumntype{6}{c}
\newcolumntype{7}{c}
\newcolumntype{8}{c}
\renewcommand*\heading[1]{\chapterfont\MakeUppercase{#1}}
\renewcommand*\beforeheading{\arrayrulecolor{CadolesBlue}\toprule}
\renewcommand*\afterheading{\midrule}
\renewcommand*\normalline{}
\renewcommand*\lastline{\bottomrule}
\definecolor{CadolesBlue}{rgb}{.16,.50,.69}
\definecolor{CadolesLightBlue}{rgb}{.31,.506,.741}
\newfontfamily\cadolesfont{Caviar Dreams}
\newfontfamily\chapterfont[Color=CadolesBlue]{Caviar Dreams}
\newfontfamily\sectionfont[Color=CadolesBlue]{Caviar Dreams}
\newfontfamily\subsectionfont[Color=CadolesLightBlue]{Caviar Dreams}
\newfontfamily\subsubsectionfont[Color=CadolesLightBlue]{Caviar Dreams}
\newcommand{\tickYes}{\color{Green}\checkmark}
\newcommand{\tickNo}{\color{red}{\hspace{1pt}\ding{55}}}
\newcommand{\wlink}[1]{\textcolor{CadolesBlue}{\underline{#1}}}
\newcommand{\classname}[1]{\texttt{\textbf{#1}}}
%\newcommand{\cadoles}{\chapterfont{Cadoles}}
\newcommand{\cadoles}{\cadolesfont\textcolor{black}{Cad}\textcolor{CadolesBlue}{ole}\textcolor{black}{s}}
\newcommand{\TitleRule}{\rule[0.5ex]{12cm}{0.5mm}}
\newcommand\espace{\vrule height 20pt width 0pt}
\newcommand{\titre}[1]{{\color{DarkBlue}\normalfont\LARGE\bfseries #1\smallskip\hrule height 1pt}\bigskip}
\renewcommand*\abstractname{Summary}
%\renewcommand{\FrenchLabelItem}{\color{DarkBlue}{\ding{68}}}
\let\oldfootnoterule\footnoterule
\renewcommand\footnoterule{\vspace*{-3pt}%
\noindent\rule{3in}{0.4pt}\vspace*{2.6pt}}% -3 + 0.4 + 2.6 = 0
%\pagestyle{headings}
\makeatletter
\renewcommand{\thesection}{}
\titleformat{\chapter}{\LARGE\chapterfont}{\thesection}{0ex}{}[\color{CadolesBlue}\hrule height 1pt]
\titleformat{\section}{\Large\sectionfont}{\thesection}{0ex}{}[\color{CadolesBlue}\hrule height 1pt]
\titleformat{\subsection}{\large\subsectionfont}{\thesection}{0ex}{}
\titleformat{\subsubsection}{\itshape\subsubsectionfont}{\thesection}{0ex}{}
\skbinput[from=rep]{style/00-entete-pied-de-page}
\def\maketitle{
\skbfigure[center]{logos/Cadoles}
\vspace{4.5cm}
\begin{flushleft}
\textbf{\Huge \cadolesfont\textcolor{CadolesBlue}{\@title}}
\end{flushleft}
\begin{center}
\color{CadolesBlue}\TitleRule
\end{center}
\begin{flushright}
\vspace{-1.5ex}
\textbf{\huge \cadolesfont\textcolor{DarkGrey}{\departement}}
\end{flushright}
\vspace{2.5cm}
\pagebreak
}
\def\origine{
\vspace{1.5cm}
\begin{flushleft}
\begin{minipage}[l]{8cm}
\skbinput[from=rep]{style/00-Coordonnees}
\end{minipage}
\end{flushleft}
}
%
% Itemize avec la petite cadoles
%
%\newenvironment{citemize}{\renewcommand{\labelitemi{$\odot$}}}
%\newenvironment{citemize}{\renewcommand{\labelitemi{\includegraphics[height=1.6ex]{inc/cadole.png}}}}
\newenvironment{citemize}{\renewcommand
\labelitemi{\includegraphics[height=1ex]{inc/cadole.png}}\begin{itemize}}{\end{itemize}}
%
% Box pour citations
%
\newsavebox{\fmbox}
\newenvironment{fmpage}[1]
{\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
{\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}}
\hypersetup{
backref=true, % Permet d'ajouter des liens dans
pagebackref=true, % les bibliographies
hyperindex=true, % Ajoute des liens dans les index.
colorlinks=true, % Colorise les liens.
breaklinks=true, % Permet le retour à la ligne dans les liens trop longs.
urlcolor= CadolesBlue, % Couleur des hyperliens.
linkcolor= CadolesBlue, % Couleur des liens internes.
bookmarks=true, % Créé des signets pour Acrobat.
bookmarksopen=true, % Si les signets Acrobat sont créés,
% les afficher complètement.
pdftitle={\@title}, % Titre du document.
% Informations apparaissant dans
pdfauthor={Cadoles}, % dans les informations du document
pdfsubject={Proposition Commerciale} % sous Acrobat.
}
%\topmargin 0in
%\leftmargin 2.5cm
%\rightmargin 2.5cm
\setlength{\hoffset}{-18pt}
\setlength{\oddsidemargin}{0pt} % Marge gauche sur pages impaires
\setlength{\evensidemargin}{9pt} % Marge gauche sur pages paires
\setlength{\marginparwidth}{54pt} % Largeur de note dans la marge
%\setlength{\textwidth}{481pt} % Largeur de la zone de texte (17cm)
\setlength{\voffset}{-18pt} % Bon pour DOS
\setlength{\marginparsep}{7pt} % Séparation de la marge
\setlength{\topmargin}{0pt} % Pas de marge en haut
\setlength{\headheight}{13pt} % Haut de page
\setlength{\headsep}{10pt} % Entre le haut de page et le texte
\setlength{\footskip}{27pt} % Bas de page + séparation
\setlength{\textheight}{708pt} % Hauteur de la zone de texte (25cm)

View File

@ -7,6 +7,7 @@ import random
import time
from os import path, makedirs, listdir
from jinja2 import Environment, FileSystemLoader
import pygit2
LICENSES = {'CC-by-sa-2.0': 'license-cc-by-sa-2.0',
}
@ -46,8 +47,42 @@ def escape_tex(value):
return newval
def normalize_branch(args):
if 'master' in args:
return path.dirname(args.master).replace('/', '')
elif 'directory' in args:
return args.directory.replace('/', '')
else:
raise Exception('No sufficient information to create branch')
def git_integration(func):
def inner(args):
try:
repo = pygit2.Repository('./')
except:
repo = None
if repo:
branch_name = normalize_branch(args)
if not branch_name in repo.branches.local:
master_ref = repo.references['refs/heads/master']
commit = master_ref.peel()
repo.branches.local.create(branch_name, commit)
# état du dépôt, si il nest pas propre, sortir
# checkout sur la branche master
# création dune branche spécifique pour le document à partir de la branche master
# création des fichiers
func(args)
if repo: # à transformer en decorateur éventuellement
print('add et commit')
# ajout tout le contenu hors presentations dans la branche master
# ajout de tout le contenu de presentations dans la branche spécifique
return inner
def main():
@git_integration
def init(args):
"""
init function
@ -69,33 +104,20 @@ def main():
root = '../'
if args.directory:
root = root + re.sub(r'[\w-]+/?', '../', args.directory)
else:
root = '../'
name = args.name
if name:
if path.splitext(name)[1] == '':
name = name + '.tex'
else:
name = get_unique_name('formation')
name = 'master.tex'
title = args.title
if not title:
title = 'FIXME'
else:
title = title
author = args.author
if not author:
author = 'Cadoles'
else:
author = author
client = args.client
if not client:
client = 'FIXME'
else:
client = client
institutes = get_institutes_logos(args.institutes)
logos_count = len(institutes) + 1
@ -110,18 +132,20 @@ def main():
content = 'sli' if document_class == 'beamer' else 'rep'
env = {'root': root,
'class': document_class,
'content': content,
'title': title,
'author': author,
'client': client,
'license': license,
'institutes': institutes,
'logos_count': logos_count}
'class': document_class,
'content': content,
'title': title,
'author': author,
'client': client,
'license': license,
'institutes': institutes,
'logos_count': logos_count}
master = TEMPLATES[document_class]['master']
master_dir = path.join('presentations', directory)
programme_dir = path.join(master_dir, 'programme')
resources = [(path.join('presentations', directory), master),
resources = [(master_dir, master),
(master_dir, 'programme.tex'),
(master_dir, 'support.tex'),
(programme_dir, 'contenu.tex'),
(programme_dir, 'duree.tex'),
(programme_dir, 'evaluation.tex'),
@ -130,9 +154,6 @@ def main():
(programme_dir, 'prerequis.tex'),
(programme_dir, 'public.tex'),
]
#('slides', 'license-cc-by-sa-2.0.tex'),
#('slides', 'preambule.tex'),
#('slides', 'title.tex')]
for directory, template_file in resources:
template = jinja_env.get_template(template_file)
rendered_template = template.render(**env)
@ -142,6 +163,7 @@ def main():
with open(path.join(directory, template_dest_name), 'w') as rendered_file:
rendered_file.write(rendered_template)
@git_integration
def update(args):
"""
update function
@ -172,6 +194,7 @@ def main():
rendered_file.write(rendered_template)
@git_integration
def outline(args):
"""
outline creation
@ -302,7 +325,7 @@ def main():
subparsers = parser.add_subparsers(help='Aide des sous-commandes')
parser_init = subparsers.add_parser('init', help='Initialisation du fichier maître')
parser_init.add_argument('-f', '--format', help="Format du document", required=True)
parser_init.add_argument('-n', '--name', help="Nom du fichier à créer", required=True)
#parser_init.add_argument('-n', '--name', help="Nom du fichier à créer", required=True)
parser_init.add_argument('-a', '--author', help="Auteur de la formation")
parser_init.add_argument('-c', '--client', help="Client")
parser_init.add_argument('-t', '--title', help="Titre de la formation")

56
templates/programme.tex Normal file
View File

@ -0,0 +1,56 @@
\documentclass[a4paper,11pt]{report}
\usepackage{skb}
\skbconfig[
root = (((root))),
rep = content,
pub = presentations,
fig = figures,
sli = slides,
acr = database/acr,
bib = database/bib
]{skblocal.tex}
\newcommand{\departement}{Cadoles Formations}
\newcommand{\numeroversion}{1.0}
\newcommand{\adresse}{29 bis, rue de lArquebuse}
\newcommand{\codepostal}{21000}
\newcommand{\ville}{Dijon}
\newcommand{\telephone}{Tél : 03 73 27 02 86}
\newcommand{\fax}{Fax : 09 72 29 61 11}
\newcommand{\siteweb}{Site : http://www.cadoles.com/}
\newcommand{\formateur}{Emmanuel Garette}
\skbinput[from=rep]{style/preambule-programme}
% TITRE DU DOCUMENT !
\title{Programme de Formation}
\author{Emmanuel Garette}
%\date{}
\begin{document}
\maketitle
\newpage
\section{Public visé}
\input{./programme/public.tex}
\section{Conditions préalables}
\input{./programme/prerequis.tex}
\section{Objectifs de la formation}
\input{./programme/objectifs.tex}
\section{Durée de la formation}
\input{./programme/duree.tex}
\section{Évaluation des acquis}
\input{./programme/evaluation.tex}
\newpage
\section{Contenu de la formation}
\input{./programme/contenu.tex}
\IfFileExists{./programme/moyens.tex}{%
\section{Moyens pédagogiques, techniques et d'encadrement}
\input{./programme/moyens.tex}
\section{Évaluation des acquis}
}{}
\end{document}

42
templates/support.tex Normal file
View File

@ -0,0 +1,42 @@
\documentclass{article}
\usepackage{skb}
\skbconfig[
root = (((root))),
rep = content,
pub = presentations,
fig = figures,
sli = slides,
acr = database/acr,
bib = database/bib
]{skblocal.tex}
\skbinput[from=rep]{style/preambule-article}
\newcommand{\departement}{Cadoles Formations}
\newcommand{\numeroversion}{0.1}
\newcommand{\adresse}{29 bis, rue de lArquebuse}
\newcommand{\codepostal}{21000}
\newcommand{\ville}{Dijon}
\newcommand{\telephone}{03 73 27 02 86}
\begin{document}
\title{(((title)))}
\author{(((author)))}
\date{{\small \today}}
\maketitle
\skbinput[from=rep]{style/title}
% Corps de la formation
%\skbinput[from=rep]{}
\skbinput[from=rep]{licences/(((license)))}
\end{document}