wpilibsuite / styleguide

Style guides for wpilibsuite projects
Other
5 stars 14 forks source link

Add link to source file from header comment #223

Open PeterJohnson opened 2 years ago

PeterJohnson commented 2 years ago

For team discoverability of GitHub source code, it might be helpful to automatically add a link in the header to the file on GitHub, similar to what RTD does. E.g.

// Copyright block
//
// This file can be found on GitHub at the following location:
// https://github.com/wpilibsuite/allwpilib/blob/main/wpilibj/src/main/java/edu/wpi/first/wpilibj/ADXL362.java

One problem with this is the link is almost certainly longer than the allowed line length, which may cause other formatters/style checkers (PMD, Checkstyle) to complain?

calcmogul commented 2 years ago

We could add a {file_url} tag to licenseupdate.py. Finding the right URL would be difficult since the origin remote isn't always upstream.

Or we could support something like the following in licenseupdate.py:

https://github.com/wpilibsuite/allwpilib/blob/main/{filename}

where {filename} expands to the file's path relative to the repo root.

PeterJohnson commented 2 years ago

I think the latter might be better, as I'm not sure how it will know where to point the base URL in file_url to?

calcmogul commented 2 years ago

Yep.

PeterJohnson commented 2 years ago

I wonder if we still should have _url in there somewhere, because theoretically we might need to escape spaces (spaces are a terrible idea for other reasons though, of course, so maybe this is a non-issue).