Debian Codegraph @

texmf-dist/doc/latex/biblatex-bookinother/documentation/generate-crossref-graphs.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # This file generate the inheritance graphs (.dot and .pdf file) from the .bib file examples.
4 # To do it, its create temporary .tex file, calling a specific .bib file (as https://github.com/plk/biber/issues/110 was rejected).
5 # It is licensed on GPL 3 licenses.
6 # https://www.gnu.org/licenses/gpl-3.0.fr.html
7 # Copyright : Maïeul Rouquette 2016-…
8
9 import os
10
11
12 #List all the files on the current directory
13 directory_files = os.listdir(".")
14
15 #Loop on them, and for the .bib file, generate the .tex, .dot and .pdf file
16 for file_name in directory_files:
17 basename, ext = os.path.splitext(file_name)
18
19 if ext != '.bib':#only the .bib file
20 continue
21
22 # write the .tex file content
23 tex_file_name = basename + ".tex"
24 tex_file_content = "\documentclass{article}\n\
25 \\usepackage[tools={bookinother,morenames},bibstyle=verbose]{biblatex-multiple-dm}\n\
26 \\usepackage[bibstyle=multiple-dm]{biblatex}\n\
27 \\usepackage{biblatex-anonymous}\n\
28 \\bibliography{" + file_name + "}\n\
29 \\begin{document}\n\
30 \\nocite{*}\n\
31 \end{document}"
32 tex_file_file = open(tex_file_name, "w")
33 tex_file_file.write(tex_file_content)
34 tex_file_file.close()
35
36 # generate the .bcf, .dot and .pdf file
37 os.system("xelatex -no-pdf " + basename)
38 os.system("biber -output-format=dot --dot-include=crossref,field " + basename)
39 os.system("dot -Gsplines=polyline -Tpdf " + basename + ".dot " + "-o " + basename + ".pdf")
40
41 # delete the temporary files, to avoid distributing it and to have cleaner folder
42 for ext in ["aux","bcf","blg","log","run.xml","tex"]:
43 os.remove(basename+"."+ext)