Skip to content
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

Example in Readme does not work #279

Open
JanStevens opened this issue Feb 26, 2016 · 9 comments
Open

Example in Readme does not work #279

JanStevens opened this issue Feb 26, 2016 · 9 comments

Comments

@JanStevens
Copy link

Hello,

Following the recommended folder structure and some example json schema's (auto generated) I cannot run prmd example rake tasks

rake aborted!
LoadError: cannot load such file -- prmd/multi_loader/

KeyError: key not found: ""

Tasks: TOP => schema:combine
(See full trace by running task with --trace)
require 'prmd/rake_tasks/combine'
require 'prmd/rake_tasks/verify'
require 'prmd/rake_tasks/doc'

namespace :schema do
  Prmd::RakeTasks::Combine.new do |t|
    t.options[:meta] = 'doc/schema/meta.json'    # use meta.yml if you prefer YAML format
    t.paths << 'schema/schemata/*'
    t.output_file = 'schema/api.json'
  end

  Prmd::RakeTasks::Verify.new do |t|
    t.files << 'schema/api.json'
  end

  Prmd::RakeTasks::Doc.new do |t|
    t.files = { 'schema/api.json' => 'schema/api.md' }
  end
end

task default: ['schema:combine', 'schema:verify', 'schema:doc']
@geemus
Copy link
Member

geemus commented Feb 26, 2016

I think the multiloader depends on file extensions to determine what to do. Is it possible one or more of the sub-schema files are lacking a file extension?

@JanStevens
Copy link
Author

Everything is json and ends in.json

@geemus
Copy link
Member

geemus commented Mar 7, 2016

@JanStevens could you share the schema, or at least the particular commands you run to generate them? Then I can hopefully work backwards from there to get this fixed. Thanks!

@clowder
Copy link

clowder commented Jun 23, 2016

I was hitting this too. The issue was the path not being expanded, switching to Dir.glob('schemas/*') fixed the issue.

@geemus
Copy link
Member

geemus commented Jun 28, 2016

@clowder mind submitting a PR? Thanks!

@clowder
Copy link

clowder commented Jun 29, 2016

@geemus On closer inspection it look like a PEBKAC issue. The example in the README works, the issue is that the OP & I were using glob syntax but it isn't supported.

Prmd::RakeTasks::Combine.new do |t|
  # Won't work, PRMD doesn't expand the glob
  t.paths << 'schema/schemata/*'

  # Will work, PRMD likes full paths to files
  t.paths << Dir['schema/schemata/*']

  # Will work, PRMD will automatically find all schema files in directories
  t.paths << 'schema/schemata'
end

@geemus
Copy link
Member

geemus commented Jun 30, 2016

Ah, the check just a bit further into the thing tries to see if the path is a directory (and globs then), but otherwise it assumes you are giving an explicit path. I'd certainly welcome your thoughts on either making the code more flexible or, barring that, improving the documentation to make it clear (or both perhaps). Thanks!

@bjnord
Copy link

bjnord commented Jul 7, 2017

For me, the problem was (as @JanStevens says above) "Following the recommended folder structure". The README (at the bottom) recommends putting things in docs/schema/* whereas the Rake tasks are configured to find them in schema/*.

Once I added the docs/ prefix to all paths in the Rake tasks, to match where the files actually were, the cannot load such file -- prmd/multi_loader/ error went away. Don't know if there's some way to produce a more helpful "not found" message in this case?

@geemus
Copy link
Member

geemus commented Jul 13, 2017

We could probably check for existence in the loader, prior to trying to open the file? I think that is the point at which things error in the unhelpful way any how. I'd certainly be happy to discuss and would welcome help on a PR.

Additionally, from the sounds of things, maybe we should just update the README suggested paths to reflect the defaults in the rake to reduce confusion?

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

No branches or pull requests

4 participants