Skip to content

Automatically read in the doc version from the cabal file #2500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,41 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import re
import sys

# -- Project information -----------------------------------------------------

project = 'haskell-language-server'
copyright = '2021, The Haskell IDE Team'
author = 'The Haskell IDE Team'

# The full version, including alpha/beta/rc tags
release = '1.3.0'
# We want to take some of the metadata from the Cabal file, especially the version.
# (otherwise it's very easy to forget to update it!)
release = None
copyright = None
author = None
versionPattern = re.compile("^version:\s*([\d.]+)")
copyrightPattern = re.compile("^copyright:\s*(.+)")
authorPattern = re.compile("^author:\s*(.+)")
for i, line in enumerate(open('../haskell-language-server.cabal')):
versionMatch = re.search(versionPattern, line)
if versionMatch:
release = versionMatch.group(1)
copyrightMatch = re.search(copyrightPattern, line)
if copyrightMatch:
copyright = copyrightMatch.group(1)
authorMatch = re.search(authorPattern, line)
if authorMatch:
author = authorMatch.group(1)

if not release:
print("Couldn't find version")
sys.exit()
if not copyright:
print("Couldn't find copyright")
sys.exit()
if not author:
print("Couldn't find author")
sys.exit()

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@

docs = pkgs.stdenv.mkDerivation {
name = "hls-docs";
src = pkgs.lib.sourceFilesBySuffices ./docs [ ".py" ".rst" ".md" ".png" ".gif" ".svg" ];
src = pkgs.lib.sourceFilesBySuffices ./. [ ".py" ".rst" ".md" ".png" ".gif" ".svg" ".cabal" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be safer to use regex so that it does not include markdown files and image files in each plugin/ghcide/...? But I haven't been generated the docs so don't know how long it takes in general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter in practice, this just affects what's hanging around in the nix build, it doesn't get processed. And we're not using this for production usage anyway, it's just for convenience.

buildInputs = [ pythonWithPackages ];
# -n gives warnings on missing link targets, -W makes warnings into errors
buildPhase = ''sphinx-build -n -W . $out'';
buildPhase = ''cd docs; sphinx-build -n -W . $out'';
dontInstall = true;
};

Expand Down