Skip to content

Commit 98bacda

Browse files
authored
Merge pull request #60 from ento/fix-indirect-deps
Fix indirect deps, remove automatic installation of Elm
2 parents 3a92933 + 7f4adbf commit 98bacda

24 files changed

Lines changed: 219 additions & 244 deletions

.travis.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,32 @@ env:
1414
global:
1515
- PIP_CACHE_DIR=$HOME/.cache/pip
1616
- PIPENV_CACHE_DIR=$HOME/.cache/pipenv
17+
- PIPENV_KEEP_OUTDATED=1
1718

1819
language: python
1920

2021
python:
21-
- 3.5
22-
- 3.6
23-
- nightly
2422

2523
matrix:
2624
include:
27-
- env: WITH_YARN=yes
28-
python: "3.5"
29-
- env: CHECK_INSTALL=yes
30-
python: "3.5"
25+
- python: "3.5"
26+
env: CHECK_INSTALL=yes
27+
- python: "3.5"
28+
- python: "3.6"
29+
- python: "3.7"
30+
dist: xenial
31+
- python: nightly
3132

3233
before_install:
3334
- pip --version
3435
- pip install codecov
3536
- pip install -U pip setuptools
36-
- |
37-
if [[ $WITH_YARN == 'yes' ]]; then
38-
# Repo for newer Node.js versions
39-
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
40-
# Repo for Yarn
41-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
42-
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
43-
sudo apt-get update -qq && sudo apt-get install -y -qq yarn
44-
fi
4537

4638
install:
4739
- pip install 'pipenv>=2018.10.9' tox-travis
4840
- pipenv --version
4941
- pipenv install --dev
42+
- git checkout Pipfile.lock # workaround until https://github.com/pypa/pipenv/pull/3304 is released
5043

5144
before_script:
5245
- git lfs version

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include src/elm_doc/assets/assets.tar.gz
44
exclude .gitmodules
55
exclude dependencies.yml
66
exclude Pipfile*
7+
exclude *.nix
78
exclude vendor
89
recursive-exclude vendor *
910
exclude workspace

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ wheel = "*"
2323
keyring = "*"
2424

2525
[requires]
26-
python_version = "3.6"
26+
python_version = "3.7"

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ You will need to enable the `--pre` flag if you're installing the latest version
1515

1616
Simplest invocation:
1717

18-
$ elm-doc . --output docs --fake-license 'SPDX license name'
18+
$ elm-doc . --output docs --fake-license 'SPDX license name' \
19+
--elm-path path/to/usually/node_modules/.bin/elm
1920

2021
The license name is required because elm-doc uses the official Elm binary to
2122
validate and generate docs; the official Elm binary only generates
@@ -41,16 +42,10 @@ and `--fake-version`.
4142
elm-doc creates a build directory named `.elm-doc` at the root of the project.
4243
You may want to ignore it in your SCM config, or you can change its path with `--build-dir`.
4344

44-
You can further point `--elm-path` at your existing installation of `elm` binary
45-
to avoid the overhead of installing Elm:
46-
47-
$ elm-doc . --output docs \
48-
--elm-path ui/node_modules/.bin/elm
49-
5045
`--validate` can check if you have all the necessary documentation in place:
5146

5247
$ elm-doc . \
53-
--elm-path ui/node_modules/.bin/elm \
48+
--elm-path ./node_modules/.bin/elm \
5449
--validate
5550

5651
`elm-doc` assumes you're working on an app, not a package; it will try to generate
@@ -59,13 +54,13 @@ documentation for all modules found in the application source directories.
5954
You can `--exclude-modules` by using [fnmatch](https://docs.python.org/3/library/fnmatch.html)
6055
patterns:
6156

62-
$ elm-doc . --output docs \
63-
--elm-path ui/node_modules/.bin/elm \
57+
$ elm-doc . --output docs --fake-license 'SPDX license name' \
58+
--elm-path ./node_modules/.bin/elm \
6459
--exclude-modules '*.Private.*,Blacklist.*'
6560

6661
or `--exclude-source-directories` entirely:
6762

68-
$ elm-doc . --output docs \
63+
$ elm-doc . --output docs --fake-license 'SPDX license name' \
6964
--elm-path ui/node_modules/.bin/elm \
7065
--exclude-source-directories generated
7166

@@ -78,7 +73,7 @@ You can also specify which files and directories to _include_ in the list of mod
7873
Note that the `--exclude` flag takes no effect if you explicitly specify which
7974
files to include, unless you add the `--force-exclusion` flag:
8075

81-
$ elm-doc . --output docs \
76+
$ elm-doc . --output docs --fake-license 'SPDX license name' \
8277
--elm-path ui/node_modules/.bin/elm \
8378
--exclude-modules '*.Private.*,Blacklist.*' \
8479
--force-exclusion \
@@ -104,9 +99,9 @@ This is the rough build process:
10499
- Populate `--fake-*` fields, including the license: these are required for a package project but not included in an application project's elm.json
105100
- Add dependencies that are listed as popular packages in the sidebar, making HTTP requests to look up the latest versions
106101
- This means the actual build / validation process will have its own elm-stuff directory
107-
- Copy source files into the build directory's `src` directory using [dirsync](https://bitbucket.org/tkhyn/dirsync/)
102+
- Copy source files into the build directory's `src` directory using rsync
108103
- An application project supports multiple source directories, while a package project supports only `src`
109-
- For each file that were copied, rewrite port delcarations to be normal functions
104+
- For each file that was copied, rewrite port delcarations to be normal functions
110105
- This is needed because ports are not allowed in package projects
111106
- Run `elm make` with the `--doc` flag on
112107
- If validating docs, exit here

dodo.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
sys.path.insert(0, str(Path(__file__).parent / 'src'))
1717

18-
from elm_doc import elm_platform, elm_project, tasks
18+
from elm_doc import elm_project, tasks
1919
from tests import conftest
2020

2121

@@ -48,7 +48,7 @@ def _create_elm_core_fixture(elm_version: str, tarball: str):
4848
shutil.rmtree(str(workspace_path / elm_project.STUFF_DIRECTORY), ignore_errors=True)
4949
with TemporaryDirectory() as tmpdir:
5050
root_path = Path(tmpdir)
51-
elm_path = elm_platform.install(root_path, elm_version)
51+
elm_path = conftest.install_elm(root_path, elm_version)
5252
elm_home_path = root_path / '.elm'
5353
try:
5454
subprocess.check_output(
@@ -182,7 +182,7 @@ def _create_package_elm_lang_org_elm_js(output_path: Path):
182182
elm_version = _read_elm_version(repo_path / 'elm.json')
183183
with TemporaryDirectory() as tmpdir:
184184
root_path = Path(tmpdir)
185-
elm_path = elm_platform.install(root_path, elm_version)
185+
elm_path = conftest.install_elm(root_path, elm_version)
186186
try:
187187
subprocess.check_output(
188188
[
@@ -219,14 +219,14 @@ def task_install_workspace_elm():
219219

220220
def _install_elm(project_path: Path):
221221
elm_version = _read_elm_version(project_path / 'elm.json')
222-
elm_platform.install(project_path, elm_version)
222+
conftest.install_elm(project_path, elm_version)
223223

224224

225225
for creator_name, creator_func in tasks.build_task_creators(
226226
workspace_path,
227227
config,
228+
elm_path,
228229
output_path,
229-
elm_path=elm_path,
230230
mount_point='/docs',
231231
).items():
232232
globals()[creator_name] = creator_func

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'Programming Language :: Python',
5050
'Programming Language :: Python :: 3.5',
5151
'Programming Language :: Python :: 3.6',
52+
'Programming Language :: Python :: 3.7',
5253
'Programming Language :: Python :: 3 :: Only',
5354
'Topic :: Software Development :: Documentation',
5455
]

shell.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
let
2+
pkgs = import <nixpkgs> {};
3+
in
4+
pkgs.mkShell {
5+
buildInputs = with pkgs; [
6+
nodejs
7+
pipenv
8+
rsync
9+
];
10+
shellHook = ''
11+
export SOURCE_DATE_EPOCH=315532800
12+
'';
13+
}

src/elm_doc/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def write(self, *args, **kwargs):
8383

8484

8585
@click.command(context_settings=dict(
86+
help_option_names=['-h', '--help'],
8687
ignore_unknown_options=True,
8788
))
8889
@click.option('--output', '-o',
@@ -187,9 +188,9 @@ def main(
187188
task_creators = build_task_creators(
188189
_resolve_path(project_path),
189190
project_config,
191+
_resolve_path(elm_path) if elm_path else None,
190192
_resolve_path(output) if output is not None else None,
191193
build_path=_resolve_path(build_dir) if build_dir is not None else None,
192-
elm_path=_resolve_path(elm_path) if elm_path is not None else None,
193194
mount_point=mount_at,
194195
validate=validate)
195196

src/elm_doc/decorators.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/elm_doc/elm_platform.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import os
2-
import subprocess
32
from pathlib import Path
4-
import json
5-
6-
from elm_doc import node_modules
7-
from elm_doc.decorators import capture_subprocess_error_as_task_error
83

94

105
# See: https://github.com/elm/compiler/blob/0.19.0/builder/src/Elm/PerUserCache.hs#L44
@@ -14,48 +9,3 @@
149
# On Windows, this is something like 'C:/Users/<user>/AppData/Roaming/<app>'.
1510
# elm-doc currently don't support Windows, so this is fine for now.
1611
ELM_HOME = Path(os.environ['ELM_HOME']) if 'ELM_HOME' in os.environ else (Path.home() / '.elm')
17-
18-
19-
def install(to: Path, elm_version: str) -> Path:
20-
npm_package = {
21-
'dependencies': {
22-
'elm': get_npm_version_range(elm_version)
23-
}
24-
}
25-
with open(str(to / 'package.json'), 'w') as f:
26-
json.dump(npm_package, f)
27-
node_modules.install(cwd=str(to))
28-
return to / 'node_modules' / '.bin' / 'elm'
29-
30-
31-
@capture_subprocess_error_as_task_error
32-
def get_node_modules_elm_path(project_root: Path):
33-
script = 'console.log(require.resolve("elm"))'
34-
# e.g. path/to/node_modules/elm/index.js
35-
elm_index_path = subprocess.check_output(
36-
['node', '-e', script],
37-
cwd=str(project_root),
38-
)
39-
# e.g. path/to/node_modules/.bin/elm
40-
return Path(elm_index_path.decode('utf-8').strip()).parent.parent / '.bin' / 'elm'
41-
42-
43-
def get_npm_version_range(elm_version: str) -> str:
44-
if _is_exact(elm_version):
45-
return elm_version
46-
min_version, gt_op, _, lt_op, max_version = elm_version.split(' ')
47-
return '{gt_op}{min_version} {lt_op}{max_version}'.format(
48-
min_version=min_version,
49-
gt_op=_flip_inequality_op(gt_op),
50-
lt_op=lt_op,
51-
max_version=max_version,
52-
)
53-
54-
55-
def _is_exact(elm_version: str) -> bool:
56-
return ' ' not in elm_version
57-
58-
59-
def _flip_inequality_op(op: str) -> str:
60-
# assume there's only one < or >
61-
return op.replace('>', '<').replace('<', '>')

0 commit comments

Comments
 (0)