Skip to content

Commit 4876e69

Browse files
michaelpjjneira
authored andcommitted
Automatically read in the doc version from the cabal file (#2500)
It was out of date. This way it will always be read in from the file, so we can forget about it. Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
1 parent 029a4f8 commit 4876e69

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

docs/conf.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,41 @@
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

17+
import re
18+
import sys
1719

1820
# -- Project information -----------------------------------------------------
1921

2022
project = 'haskell-language-server'
21-
copyright = '2021, The Haskell IDE Team'
22-
author = 'The Haskell IDE Team'
2323

24-
# The full version, including alpha/beta/rc tags
25-
release = '1.3.0'
24+
# We want to take some of the metadata from the Cabal file, especially the version.
25+
# (otherwise it's very easy to forget to update it!)
26+
release = None
27+
copyright = None
28+
author = None
29+
versionPattern = re.compile("^version:\s*([\d.]+)")
30+
copyrightPattern = re.compile("^copyright:\s*(.+)")
31+
authorPattern = re.compile("^author:\s*(.+)")
32+
for i, line in enumerate(open('../haskell-language-server.cabal')):
33+
versionMatch = re.search(versionPattern, line)
34+
if versionMatch:
35+
release = versionMatch.group(1)
36+
copyrightMatch = re.search(copyrightPattern, line)
37+
if copyrightMatch:
38+
copyright = copyrightMatch.group(1)
39+
authorMatch = re.search(authorPattern, line)
40+
if authorMatch:
41+
author = authorMatch.group(1)
2642

43+
if not release:
44+
print("Couldn't find version")
45+
sys.exit()
46+
if not copyright:
47+
print("Couldn't find copyright")
48+
sys.exit()
49+
if not author:
50+
print("Couldn't find author")
51+
sys.exit()
2752

2853
# -- General configuration ---------------------------------------------------
2954

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@
179179

180180
docs = pkgs.stdenv.mkDerivation {
181181
name = "hls-docs";
182-
src = pkgs.lib.sourceFilesBySuffices ./docs [ ".py" ".rst" ".md" ".png" ".gif" ".svg" ];
182+
src = pkgs.lib.sourceFilesBySuffices ./. [ ".py" ".rst" ".md" ".png" ".gif" ".svg" ".cabal" ];
183183
buildInputs = [ pythonWithPackages ];
184184
# -n gives warnings on missing link targets, -W makes warnings into errors
185-
buildPhase = ''sphinx-build -n -W . $out'';
185+
buildPhase = ''cd docs; sphinx-build -n -W . $out'';
186186
dontInstall = true;
187187
};
188188

0 commit comments

Comments
 (0)