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
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).
Not a direct answer, only elements :
git diff
has the -G
option to keep only patches that match a certain regexp. There doesn't seem to be a flag to exclude lines matching your date line, but maybe you will be imaginative enough to build a regexp that keeps anything but your date line.diff
has such an option (diff -I
), so if you can figure a way to feed the diff generated by git to diff, you are good to go.meld
is a graphical diff viewer, which works well enough with git -- e.g. invoking meld dir/
on a directory of your project opens a window displaying all the files having differences with the HEAD
-- and which can take regexps to ignore certain lines (Edit > Preferences > Text filters). It is packaged for linux distros (at least for Ubuntu), and the website claims it also runs on MacOS X and Windows (I haven't tried).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.
I'm not familiar with yard but there is no way to make git ignore parts of a file.
The easiest solution would be modifying your build process to run a custom script that removes the data from the generated files or checks the git-diff if only the date was changed and in that case revert the date change.
However, not versioning any generated code/files at all would be much cleaner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With