Skip to content

Quotes psc-docs examples. - #1814

Merged
paf31 merged 1 commit into
purescript:masterfrom
damncabbage:topic/psc-docs-help-fix
Jan 19, 2016
Merged

Quotes psc-docs examples.#1814
paf31 merged 1 commit into
purescript:masterfrom
damncabbage:topic/psc-docs-help-fix

Conversation

@damncabbage

Copy link
Copy Markdown
Contributor

Currently:

Examples:
  print documentation for Data.List to stdout:
    psc-docs src/**/*.purs bower_components/*/src/**/*.purs \
      --docgen Data.List

With this change:

Examples:
  print documentation for Data.List to stdout:
    psc-docs 'src/**/*.purs' 'bower_components/*/src/**/*.purs' \
      --docgen Data.List

This was triggered by a good half-hour of digging around in Pulp trying to figure out why the examples from the psc-docs help weren't working. I eventually figured out the shell expansion was the difference between pulp docs working and my manual attempts not.

For example:

$ psc-docs 'src/**/*.purs' 'bower_components/purescript-*/src/**/*.purs' | head -n 3
## Module Main

#### `globals`
$ psc-docs src/**/*.purs bower_components/purescript-*/src/**/*.purs | head -n 3
Error found:
in module Node.FS
at /Users/rhoward/code/purescript/pulp/bower_components/purescript-node-fs/src/Node/FS.purs line 15, column 1 - line 18, column 1

  Unknown module Prelude


See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
or to contribute content related to this error.

I don't know why the latter fails, only that it does right now.

@damncabbage

Copy link
Copy Markdown
Contributor Author

A side-note (asked in IRC): is the stack.yaml for this repo to have a null for the value extra-deps, instead of []? My copy of here Stack had a whinge until I made the edit myself.

@garyb

garyb commented Jan 10, 2016

Copy link
Copy Markdown
Member

It's odd, I've seen someone else say they need quotes for the globs to work too (in fact they don't work if I use single quotes, but do with double quotes), but I definitely do not on Windows or OSX. What platform/shell are you using?

@damncabbage

Copy link
Copy Markdown
Contributor Author
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)

(OS X, 10.10.5)

@natefaubion

Copy link
Copy Markdown
Contributor

It requires quotes, because otherwise bash will try to expand the globs. Which just means you'll probably end up passing in an empty list of files.

@damncabbage

Copy link
Copy Markdown
Contributor Author

The key seems to be what glob-expansion capabilities the shell has. Assume a directory structure that looks like:

abc/
  |-- file.purs
  '-- def/
        '-- file2.purs

Bash 3:

$ ls abc/**/*.purs
abc/def/file2.purs

Bash 4 and zsh have proper **-expansion (my assumption from reading docs; I have access to neither from here at the moment):

$ ls abc/**/*.purs
abc/file.purs
abc/def/file2.purs

In my particular example, purescript-prelude is a package with a src/Prelude.purs which isn't getting picked up when Bash 3 expands the **.

So the example in the current help text works by accident in some environments because some shells have proper expansion and some don't. When given to psc-docs as a quoted string, System.FilePath.Glob will always perform the ** expansion correctly.

@garyb

garyb commented Jan 10, 2016

Copy link
Copy Markdown
Member

Do double quotes work for you then? As single quoting the globs prevents them from working at all on Windows at least, although double quoting does still work.

@damncabbage
damncabbage force-pushed the topic/psc-docs-help-fix branch from a10c26b to 9aa05e3 Compare January 10, 2016 15:40
@damncabbage

Copy link
Copy Markdown
Contributor Author

Oh damn, I forgot about Windows again. Yes, double-quotes work; I've updated the branch to reflect this.

@damncabbage damncabbage changed the title Single-quotes psc-docs examples. Quotes psc-docs examples. Jan 11, 2016
@hdgarrood

Copy link
Copy Markdown
Contributor

LGTM 👍

paf31 added a commit that referenced this pull request Jan 19, 2016
@paf31
paf31 merged commit d1c7635 into purescript:master Jan 19, 2016
@paf31

paf31 commented Jan 19, 2016

Copy link
Copy Markdown
Contributor

Thanks!

@damncabbage
damncabbage deleted the topic/psc-docs-help-fix branch January 19, 2016 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants