Search code examples
gityard

How to customize diff git to ignore yard date generation


I'm using yard to generate the documenation of my project. Even thought the documentation can generated and so don't really need to be versionned, we decided to do so, because it makes it easier to see the impact of code (comment) change in the actual documenation.

The problem is each time yard generate the documenation, it changes the date at the beginning of each file resulting in all the files being seen as changed.

Is there a way to either tell git to ignore those line to detect if files have changed or alternatively a way to configure yard to not regenerate file if they are identical ?

Thanks

Update

I know I can do a script or whatever, which clean the files if only the date has changed. So my question is there is a Git way to do , .i.e should I bother read about diff drivers or should I do the clean script.

If I were going toward the cleaning path, would that be better to do so using a git hook or integrating it in the doc generation.

Ultimately, I'm interested in any other way to track changes due to a particular commit in the generated doc.

I haven't really explained what is my problem (and why I am trying to version things which don't need to be) so there we go.

Sometime, a little modification in the code screw up the documentation, therefore I would be able to see the impact of a commit regarding the documentation.

Example : I use modeline for vim (a comment at the first line of a file telling vim different information)

Know I have a file with the documentation of a module

#vi: my vim setting 
# Documentation of module A
module A
  .... some code

end

And somewhere else I use this module

#vi : my vim setting

           ( 2 blank lines)
module A
   .... some different code
end

At that point, everything is fine and the documentation for A would be Documentation of module A. However if some one (like me) delete a blank line in the last file and leave only one (yes I let 2 blanks lines between the modeline and the code), then yard think the modeline is the documentation for module A which will be vi : my vim setting.

The problem is, there is no way to detect the doc as been screwed up, except by looking at every single pages. Using git, I can quickly see and check what as changed and even find when (which is important, because then I can figure out why it changed).


Solution

  • Is it sufficient to not have the dates in the files at all?

    The yard-specific solution (but not git-specific), if you don't actually use those dates - get yard to not generate them in the first place:

    create an empty file in customtemplates/default/layout/html/footer.erb and then include it in your template:

    • using the command line

      yardoc --template-path ./customtemplates
      
    • using a Rakefile

      YARD::Rake::YardocTask.new do |yardoc|
          yardoc.options = ["--template-path", "./customtemplates"]
      end
      

    (Alternately, if you still want an acknowledgement to Yard, you can put the following in the customtemplates/default/layout/html/footer.erb file)

    <div id="footer">
         Generated by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>.
    </div>
    

    or you can put in your own footer, with your company logo or other information.