Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
RWTHmoodle
exam-scan
Commits
ce0bdd7b
Commit
ce0bdd7b
authored
Apr 30, 2021
by
Christian Rohlfing
Browse files
generate rst files automatically
parent
932eea49
Pipeline
#457641
failed with stage
in 1 minute and 47 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
ce0bdd7b
...
...
@@ -6,3 +6,4 @@ pdfs_encrypted/*
.vscode
**/__pycache__
venv/*
docs/source/_template.rst
0 → 100644
View file @
ce0bdd7b
<header>
.. toctree::
:maxdepth: 3
.. autoprogram:: <file>:_parser
:prog: <file>.py
API
===
.. automodule:: <file>
:members:
docs/source/generate_rst.py
0 → 100644
View file @
ce0bdd7b
#!/usr/bin/env python
import
os
def
generateFiles
(
file_infos
,
template_path
,
out_dir
):
""" insert figures into latex template
"""
with
open
(
template_path
,
"r"
)
as
template_handle
:
template_string
=
template_handle
.
read
()
for
file_info
in
file_infos
:
file
=
file_info
[
'file'
]
title
=
file_info
[
'title'
]
line
=
'*'
*
len
(
title
)
header
=
"{title}
\n
{line}"
.
format
(
title
=
title
,
line
=
line
)
s
=
template_string
.
replace
(
"<file>"
,
file
)
s
=
s
.
replace
(
"<header>"
,
header
)
out_file
=
"{file}.rst"
.
format
(
file
=
file
)
out_path
=
os
.
path
.
join
(
out_dir
,
out_file
)
if
os
.
path
.
exists
(
out_path
):
print
(
"Overwriting {file}."
.
format
(
file
=
out_file
))
with
open
(
out_path
,
'w'
)
as
out_handle
:
out_handle
.
write
(
s
)
print
(
"Done."
)
if
__name__
==
'__main__'
:
""" Main routine
"""
file_infos
=
[
{
'file'
:
'watermark'
,
'title'
:
'Watermark'
},
{
'file'
:
'batch'
,
'title'
:
'Batch'
},
{
'file'
:
'encrypt'
,
'title'
:
'Encrypt'
},
{
'file'
:
'preparemoodle'
,
'title'
:
'Prepare Moodle'
},
{
'file'
:
'preparepdf'
,
'title'
:
'Prepare PDFs'
},
{
'file'
:
'renamescans'
,
'title'
:
'Rename Scans'
},
{
'file'
:
'supplements'
,
'title'
:
'Supplements'
},
]
generateFiles
(
file_infos
=
file_infos
,
template_path
=
'./docs/source/_template.rst'
,
out_dir
=
'./docs/source/'
)
docs/source/preparepdf.rst
View file @
ce0bdd7b
Prepare
PDFs
************
*
Prepare PDFs
************
.. toctree::
:maxdepth: 3
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment