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

Verb compiler ignores custom docs path passed in options #7

Open
jwtd opened this issue Jan 5, 2015 · 0 comments
Open

Verb compiler ignores custom docs path passed in options #7

jwtd opened this issue Jan 5, 2015 · 0 comments

Comments

@jwtd
Copy link

jwtd commented Jan 5, 2015

In projects, it is not uncommon to use a docs directory off the root as the destination for auto-generated code documentation from JSDocs, docco, yuidocs, whatever. This conflicts with verb's default preference for using that directory to store partials.

I noticed that the grunt-verb task specified a docs option in the default block:

    var options = this.options({
      sep: '\n',
      ext: '.md',
      data: ['docs/*.{json,yml}'],
      prefixBase: true,
      cwd: process.cwd(),
      destBase: process.cwd(),
      docs: 'docs'
    });

I setup a verb config block in Gruntfile.js that passed a docs parameter with a custom path...

// In Gruntfile.js

    // Generate README.md using verb
    verb: {
      docs: "src/docs/verb",
      data: [
         "package.json",
         "src/docs/verb/*.{json,yml}"
      ],
      changelog: {
        files:[ 
          { 
            src:  "src/docs/verb/changelog.tmpl.md", 
            dest: "src/docs/verb/changelog.md"
          }
        ]
      },
      readme: {
        files:[ 
          { 
            src:  "src/docs/verb/README.tmpl.md", 
            dest: "README.md"
          }
        ]
      },
      all: {
        files:[ 
          {
            expand: true, 
            cwd: 'src/docs/verb', 
            src: ['src/docs/verb/**/*.tmpl.md'], 
            dest: '.', 
            ext: '.md'
          }
        ]
      }
    },

The task failed to find the files at the custom path, so I traced the option through to the point of page generation. When I inspected verb's properties just before the verb.process(src); call, I saw that verb.docs was still set to the default value.

I was able to get it working by updating line 34 as follows...

    // OLD LINE: This call doesn't pick up verb task config from Gruntfile.js
    //verb.options = _.extend(verb.options || {}, options);

    // NEW LINE: Merge grunt.config('verb') into verb.options after the default task options
    verb.options = _.extend(verb.options || {}, options, grunt.config('verb'));

    // NEW LINE: Verb does not pick up the docs param if set in .options, so explicitly set it here
    verb.docs = verb.options.docs;

This isn't the correct fix IMHO. It just gets it working. It seems like verb itself is failing to allow a docs param in verb.options to override the default. That being the case, maybe I should have logged this issue over on that project?

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

1 participant