Skip to content

Commit 5baf7ff

Browse files
authored
Merge pull request #13 from flintlib/citation
Automate updating of citation block
2 parents f02bc5b + 82fc017 commit 5baf7ff

File tree

5 files changed

+90
-37
lines changed

5 files changed

+90
-37
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
AUTHORS
22
src/downloads.txt
3+
src/citation.txt

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ $ python3 downloads.py ${PATH_TO_DEST}
88
where `${PATH_TO_DEST}/download` is the path to the directory that contains all
99
PDF-files and compressed releases (probably `~/apps/flintlib_org/`).
1010

11+
Furthermore, we also generate `src/citation.txt` that is being used to generate
12+
`${DEST}/citation.html`. To generate the source file, run
13+
```
14+
$ python3 citation.py
15+
```
16+
This uses HISTORY, so make sure that HISTORY is ordered and up-to-date.
17+
1118
Following this, generate all HTML pages via
1219
```
1320
$ python3 build.py ${PATH_TO_DEST}

build.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
indent = 11
133133

134134
urllib.request.urlretrieve("https://raw.githubusercontent.com/flintlib/flint/refs/heads/main/AUTHORS", "AUTHORS")
135-
authors_data = open("AUTHORS").read().splitlines()
135+
authors_data = open("AUTHORS", encoding="utf-8").read().splitlines()
136136

137137
lines = authors_data[authors_data.index("Major contributors")+2 : authors_data.index("Other contributors")]
138138
lines_contributors = authors_data[authors_data.index("Other contributors")+5 : authors_data.index("Other credits")]
@@ -243,6 +243,7 @@
243243
source_suffix = ".txt"
244244
pages = [
245245
"index",
246+
"citation",
246247
"applications",
247248
"news",
248249
"documentation",
@@ -261,7 +262,7 @@
261262
text = ""
262263
title = "Documentation"
263264
else:
264-
text = open(source_prefix + page + source_suffix, "r").read()
265+
text = open(source_prefix + page + source_suffix, "r", encoding="utf-8").read()
265266
title = text[text.find("<h2>")+4 : text.find("</h2>")]
266267
page_want_katex.append("%WANT_KATEX" in text)
267268
text = text.replace("%AUTHORLIST", authorlist)
@@ -312,7 +313,7 @@
312313
title = " - " + title
313314

314315
path = sys.argv[1]
315-
fp = open(path + "/" + pages[i] + ".html", "w")
316+
fp = open(path + "/" + pages[i] + ".html", "w", encoding="utf-8")
316317
fp.write(PAGE_TOP.replace("TITLE", title).replace("MENU", menu).replace("%KATEX%", PAGE_KATEX if page_want_katex[i] else ""))
317318
fp.write(page_texts[i])
318319
fp.write(PAGE_BOTTOM.replace("TIMESTAMP", timestamp))

citation.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# citation.py: generate citation.txt
2+
3+
import sys
4+
import re
5+
6+
if len(sys.argv) != 1:
7+
print("Usage: python3 citation.py")
8+
exit(1)
9+
10+
output = "src/citation.txt"
11+
12+
# Read HISTORY
13+
with open('HISTORY', 'r') as file:
14+
history_lines = file.read()
15+
16+
version = ""
17+
year = ""
18+
19+
# NOTE: We do not capture 3.1.3-p1. We just want the last proper version.
20+
pattern = re.compile(r"(\d+)\.(\d+).(\d+)\s+(\d{4})-\d{2}-\d{2}")
21+
for line in history_lines.splitlines():
22+
match = pattern.match(line)
23+
if match:
24+
version = f"{match.group(1)}.{match.group(2)}.{match.group(3)}"
25+
year = f"{match.group(4)}"
26+
27+
page = r"""<h2>Citing FLINT</h2>
28+
29+
<p>When citing FLINT, the following form is recommended:</p>
30+
31+
<blockquote>The FLINT team. FLINT: Fast Library for Number Theory, """ + year + r""".
32+
Version """ + version + r""", https://flintlib.org.</blockquote>
33+
34+
<pre>
35+
@manual{flint,
36+
key = {{FLINT}},
37+
author = {The {FLINT} team},
38+
title = {{FLINT}: {F}ast {L}ibrary for {N}umber {T}heory},
39+
year = {""" + year + r"""},
40+
note = {Version """ + version + r""", \url{https://flintlib.org}}
41+
}
42+
</pre>
43+
44+
<p>
45+
Please consider also looking up whether there is a paper discussing
46+
the specific feature(s) in FLINT which you are using. In many cases, there is such a paper!
47+
For example, research using the ball arithmetic component of FLINT (Arb) may cite:</p>
48+
49+
<blockquote>
50+
F. Johansson. "Arb: efficient arbitrary-precision midpoint-radius interval arithmetic", IEEE Transactions on Computers, 66(8):1281-1292, 2017. DOI: <a href="https://doi.org/10.1109/TC.2017.2690633">10.1109/TC.2017.2690633</a>
51+
</blockquote>
52+
53+
<pre>
54+
@article{7891956,
55+
author = {Fredrik Johansson},
56+
journal = {{IEEE} Transactions on Computers},
57+
title = {{A}rb: Efficient Arbitrary-Precision Midpoint-Radius Interval Arithmetic},
58+
year = {2017},
59+
volume = {66},
60+
number = {8},
61+
pages = {1281-1292},
62+
doi = {10.1109/TC.2017.2690633}
63+
}
64+
</pre>
65+
66+
<p>Research using FLINT's number fields may cite:</p>
67+
68+
<blockquote>William B. Hart. "ANTIC: Algebraic number theory in C", Computeralgebra-Rundbrief: Vol. 56, 2015</blockquote>
69+
70+
<p>Many other references can be found <a href="https://www.flintlib.org/doc/references.html">in the bibliography of the FLINT documentation</a>.</p>
71+
72+
<p>For a list of changes in each release, see the <a href="https://www.flintlib.org/doc/history.html">history</a> section of the documentation.</p>
73+
"""
74+
75+
with open(output, "w") as file:
76+
file.write(page)

src/authors.txt

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h2>Authors and credits</h2>
1+
<h2>Authors</h2>
22

33
<h3>Brief project history</h3>
44

@@ -51,41 +51,9 @@ architecture-specific testing.</li>
5151

5252
<li>
5353
Some code (notably longlong.h and clz_tab.c) has been used from the GMP library,
54-
whose main author is Torbjorn Granlund. FLINT also includes code from the MPFR
54+
whose main author is Torbjörn Granlund. FLINT also includes code from the MPFR
5555
library developed by Guillaume Hanrot, Vincent Lefèvre, Patrick Pélissier,
5656
Philippe Théveny, Paul Zimmermann and others.
5757
</li>
5858

5959
</ul>
60-
61-
<h3>Citing FLINT</h3>
62-
63-
<p>A general citation of the following form is recommended:</p>
64-
65-
<blockquote>The FLINT team. FLINT: Fast Library for Number Theory, 2023. Version 3.0.0, https://flintlib.org.</blockquote>
66-
67-
<pre>
68-
@manual{flint,
69-
key = {FLINT},
70-
author = {The {FLINT} team},
71-
title = {{FLINT}: {F}ast {L}ibrary for {N}umber {T}heory},
72-
year = {2023},
73-
note = {Version 3.0.0, \url{https://flintlib.org}}
74-
}
75-
</pre>
76-
77-
<p>
78-
Please consider also looking up whether there is a paper discussing
79-
the specific feature(s) in FLINT which you are using. In many cases, there is such a paper!
80-
For example, research using the ball arithmetic component of FLINT (Arb) may cite:</p>
81-
82-
<blockquote>
83-
F. Johansson. "Arb: efficient arbitrary-precision midpoint-radius interval arithmetic", IEEE Transactions on Computers, 66(8):1281-1292, 2017. DOI: <a href="https://doi.org/10.1109/TC.2017.2690633">10.1109/TC.2017.2690633</a>
84-
</blockquote>
85-
86-
<p>Research using FLINT's number fields may cite:</p>
87-
88-
<blockquote>William B. Hart. "ANTIC: Algebraic number theory in C", Computeralgebra-Rundbrief: Vol. 56, 2015</blockquote>
89-
90-
<p>Many other references can be found <a href="https://www.flintlib.org/doc/references.html">in the bibliography of the FLINT documentation</a>.</p>
91-

0 commit comments

Comments
 (0)