Problem/Motivation
Module and theme developers cannot tell, by looking at the code/documentation alone, when a particular function was introduced. On api.drupal.org, you can tell whether a function exists in Drupal 6/7/8, but you can't tell that, for example, it first appeared in Drupal 7.3.
Note that it is possible to use git commands to figure out when a function was introduced. Several comments on this issue explain how to do it.
Proposed resolution
To fix this, it is proposed to use the Doxygen @since tag in documentation headers, to document functions that were added to a branch after the first full release of the branch.
Proposed documentation standard (to be added to http://drupal.org/node/1354):
------------------
For any new hooks, functions, methods, constants, etc. that are added to a branch after the first full release on that branch, and that are API functions (i.e., intended for use by module/theme developers, meaning any function whose name does not start with an underscore), add the following to the documentation header, at the bottom:
* @since Function added in 7.2.
(replace Function with Hook, Constant, etc. if something other than a function was added).
If an API function/method had a new argument added to it after the first full release on that branch, use:
* @since Argument $foo added in 7.10.
Note that the developer adding the new function, hook, etc. may not know what version their patch will be added to. So, they can use the following syntax:
* @since Function added in {UNKNOWN}
At the time the patch is committed, the committer should know what the next release version will be, and can change the {UNKNOWN} to the correct version number.
-------------
Alternate resolution
The alternative to this proposal is to make a documentation page explaining how to use git to figure out when a function has been introduced, and get this information better disseminated amongst developers.
Remaining tasks
a) Adopt documentation standard in Proposed Resolution above, and update node/1354.
b) If the standard is adopted by the community, review the patch in #46 in detail to make sure the specific @since tags are appropriate, and get it committed to Drupal 7.
c) If the standard is adopted, get a fix for #1456460: Display point release versions on api.drupal.org using the @since tag into the API module.
User interface changes
None.
API changes
None.
Original report by tsvenson
Update the documentation standard and add the @since tag to all functions that has been added to core after 7.0 was released. This is to make it easier for contrib developers to identify the lowest core version their module require.
In IDE's such as Netbeans the it will also show up using the integrated code-completion and popup-documentation.
Once #1456460: Display point release versions on api.drupal.org using the @since tag is implemented, it will also show up on api.drupal.org.
| Comment | File | Size | Author |
|---|---|---|---|
| #46 | adding_since_to_comments-1462360-46.patch | 43.8 KB | tsvenson |
| #36 | adding_since_to_comments-1462360-36.patch | 27.41 KB | tsvenson |
| #35 | adding_since_to_comments-1462360-35.patch | 9.91 KB | tsvenson |
| #31 | adding_since_to_comments-1462360-31.patch | 10.58 KB | tsvenson |
| #28 | adding_since_to_comments-1462360-25.patch | 11.08 KB | tsvenson |
Comments
Comment #1
jhodgdonIssues for discussing new coding standards need a tag. :)
So, we need some buy-in by the 7.x branch maintainer, the 8.x branch maintainer (after 8.0 is released), and the core development team in general that they are committed to adding @since tag to new functions going forward. tsvenson has volunteered to take care of patching things between 7.0 and now.
I give a +1 to the idea -- tsvenson has made an eloquent case for why this would be useful, and points to php.net as an example whose function docs have this information. But the idea won't be good if the core dev team is not committed to maintaining it going forward... I've also committed to implementing the @since on api.drupal.org if it's adopted. :)
Proposed standard:
------------
For any new functions, methods, constants, etc. that are added to a branch after the first full release, add the following to their documentation header, at the bottom:
-------------
The problem is that when someone is developing the function, they don't really know what version it will get into. So they'll need to kind of guess, and then in the final commit I guess the committer will know for sure if it's the right version and could adjust? Hmmm...
Comment #2
dave reidYou should be able to know what the next core release would be based on logic and the last known release, especially since we announce security releases ahead of time too.
Comment #3
tsvenson commentedI have identified one extra task this will add before rolling out a new release. If the new release is a dual one (security and bug release). If so, then any new functions will need a +1 point bump before release.
It shouldn't be to difficult to keep track on that though.
I'm not sure bottom is the right place to add the @since tag. For functions with extensive documentation they are easy to miss. See drupal_add_css() for an example of documentation that forces you to scroll a lot in the Netbeans code completion.
Also, PHP has this information at the top so developers are used to finding it there.
Comment #4
jhodgdonRE #2 - yes, at the time the patch is committed, definitely you should know what the next release number will be. But at the time the patch is first written, you might not know when it will be committed. :)
RE #3 (placement of the @since) - I think it could be displayed at the top of api.drupal.org pages, but I think the bottom, where the @see, @ingroup, and other similar tags go, is the right place to put it in the comments.
Comment #5
tsvenson commentedI've done some testing with the placement of @since and how the code completion/help in Netbeans use it. Placing at the top or before params does not work. Netbeans reformats it and places it after params anyways. Also, if at the top it will treat all text until next @ as part of itself.
We can place it both above and under @see and it will be retaining that order. But for conformity, having it as the last possibly tag is probably a good idea. Disadvantage of course is that it will be rather easy to miss it there.
Thought: Does the coder module parse these tags? If so, then it shouldn't be too difficult to make coder check the since and compare it with the core keyword in the .info file.
Comment #6
jhodgdonOK. So the next thing to do is either:
a) Propose an alternative to the standard proposed in #1 or
b) Gather some representatives of the core dev community and core committers to agree to this as being a good standard for Drupal 7 and beyond.
Once that's agreed upon, we can then move forward on a patch.
Comment #7
tsvenson commenteda) The info about @since says:
So it can actually be used to document and track pretty much everything. However, that would be impractical for us.
Your proposal in #1 is good for me. Alternatively it could also be "@since Version 7.8". However, it will be important that it is governed by the cosding standard so that other modules, such as coder, easily can parse and make use of it.
So +1 for just "@since Major.minor" from me to avoid any typos etc...
b) How do we alert the core devs/maintainers to get their input and smiley faces for this?
Comment #8
xjmHere is how to find when a function was added in, as well as much other rich information, without requiring developers to maintain the data in multiple places, and also without needing to clone the repo, which tsvenson expressed concern about doing.
hook_field_widget_form_alter(without parens).You now have the exact point in the history of Drupal that the function definition was added or updated, with no need for anyone to maintain the information redundantly in the codebase. Edit: if it's an update, you can also see the last update by clicking the blame link again.
Edit: Boiling down to bullets point since I got kind of ranty there, sorry. :)
Comment #9
jhodgdonxjm: thanks for writing up that explanation -- we should put it into the Community Documentation somewhere, along with an explanation of how to use Git Blame. And then make sure a link to that page is on api.drupal.org in a prominent location.
I don't think that it is actually all that feasible to add blame information directly on api.drupal.org, though, if that is what you were suggesting. I am not sure how the API module could (a) figure out what git repository to use or (b) figure out which exact blame command to run or (c) display the output. It's just not that tied in with git, and I don't think we probably want to build that... it seems complicated?
Comment #10
xjmMaybe not in api.module itself; maybe in an added form on the page. The API doc already has the line numbers the function belongs to, no? We don't expose it, but it knows. A script could run a git blame for that line, get a hash, look forward for the right tag.
Edit: I am just brainstorming; as I said, this information is so rarely relevant or needed that I don't think it's worth doing at all, personally. But the nice thing about Drupal is that if someone else really thinks it's a good idea, they can work on it and we will still help them out. :) That is, to me, much better than putting the burden on developers who will probably look in change notices and/or their git log.
Comment #11
tsvenson commented@xjm: While finding it using your method works, just think how much work that will mean for a new Drupal developer. I am just taking my own baby steps in coding modules and thus have very few functions in my head or a general feeling for if e certain feature came in core or later.
Also, in http://groups.drupal.org/node/210973#comment-700123 and http://groups.drupal.org/node/210973#comment-696488 webchick clearly indicates that introducing new features in point releases both is a good thing and something that will happen much more often than before D7.
D7 will be supported for minimum 4-5 years more and there will be a lot added to it.
Since very few users have core committing rights, then I don't think it will add very much to the workflow for making sure the @since tag is added to the right places.
Then if the coder module adds support for it to, then its a simple matter of just running your code through it and you know what the lowest core version dependency is.
The little extra time spent on adding @since will save a lot time in the end and make it easier for new developers to get started.
I also believe this can prevent a lot of pain when it comes to support and updating. Not every site is keeping core updated. They might update or add a module that uses a feature not existing in their version. First thought when it breaks doesn't necessarily have to be they are using the wrong core, especially if modules has 7.x as core dependency.
Comment #12
jhodgdonJust to clarify... The API module does not know what git repository the code it displays is coming from, and indeed it is quite likely it comes from more than one git repository (or thousands, in the case of some sites running the API module). So it will not really be feasible for api.drupal.org to display information from git blame.
If we want the information to be displayed directly on api.drupal.org, then we will need to incur the maintenance cost of putting the @since tags into the functions. Again, the proposal here is *only* to add it to functions added since the original full release (i.e., functions added since 7.0 for the 7.x branch). We're talking about something like 10 functions.
The development burden, as I mentioned in comment #1 above, is that the developer of the patch does not know when it will be committed, so it is not easy for them to do the @since. So it pretty much has to be done at the last moment or by the committer (or the committer may need to update what is in the @since tag). That is one more thing for committers to think about... not sure if that is acceptable to Dries, webchick, and catch (won't affect me since I'm not committing these types of patches).
On the other hand, as xjm has been pointing out in IRC, if there are only 10 functions that have been added so far in 7.x since 7.0, do we really even need to bother with this? How likely is it that a contrib module developer is (a) going to know about and use one of these new functions and (b) someone will be running an outdated 7.x version of Drupal and their module won't work? In that case, the user can just update Drupal to the latest version and they will be fine... so ... what's the problem this is solving, really?
Comment #13
tsvenson commentedOne easy way to avoid confusion when/if there is security releases would be to simply to the following:
That way the committer will know exactly which point release the new feature will be in. Simply the next even one.
As an added bonus, everyone will then also know what versions are security fixes only and which ones contain bug fixes and other stuff.
Comment #14
dave reidI would pain to have API module be hard-coded to running git shell commands (and hence to Git) just to display information that is already a well-supported PHP documentation standard and would only affect less than 10 functions for the entire Drupal 7 code base (we haven't added that many things since 7.0)? I feel like we are severely overestimating the effort here. We don't need to add @since tags to every single new function being added to Drupal 8 right now, only new functions added *after* Drupal 8.0 is released. API module already gives us the major core versions that a function is available from so we don't need to add more work and be adding this to every single function in core.
For Drupal 7 this would affect the following functions that I know of:
hook_field_widget_form_alter() - 7.7
menu_tree_set_path() - 7.9
menu_tree_get_path() - 7.9
format_string() - 7.9
A demonstration of how @since is used on PHP.net. This is the array_fill_keys() function. It was introduced in PHP 5.2. I can see that information right up front and don't have to scan the comment section to figure out that I can only use this function if my module requires PHP 5.2. It should be just as easy to see that on api.drupal.org.
For concerns about getting the version number right before the version has been tagged, I did a bit more research I've found that Wordpress (http://codex.wordpress.org/Inline_Documentation) and other PHP projects use
@since {@internal Unknown}which is then replaced after the release has been made (so in theory the -dev release always contains the proper version).Comment #15
xjmAlright, I said I was unfollowing this, but davereid (as usual) talks unreasonable amounts of sense. I would be less, uh, tense, toward something that machines can do for us. The remaining disadvantages I can see are:
@since insert_placeholder_here(I guess this becomes a part of the reviewers' and committers' tasks when checking for API changes to make sure it's there. Upshot, nice red flag for an API change.)If we can come up with good solutions for those two points, then I will willingly help contributors comply with this standard.
Edit: I spelled davereid's name wrong, which is impressive.
Comment #16
dave reidI bet we could come up with some kind of helpful core-tag command or script that helps take care of some of the things that our core committers have to do normally (changing the VERSION constant).
Comment #17
webchickThis is an interesting thing which I'm not quite sure how to handle: http://drupal.org/node/336697 New, optional parameters to existing functions?
However, count me as a definite +1 for this initiative if we can figure out the syntaxes and whatnot. Like Dave said, this really doesn't come up /that/ much, and I don't even think we need to be so thorough as to define /every/ new function during point releases... just the ones that are API functions we intend developers to call.
The "we don't know if the next release is 7.13 or 7.14" thing is annoying, for sure. But whatever, there are worse problems to have.
Comment #18
jhodgdonOK, it sounds like we're converging on "Use the @since tag" as the right solution here, and we need to agree on some details. Here is a new proposed standard for discussion:
------------
For any new functions, methods, constants, etc. that are added to a branch after the first full release, and that are intended for use by module/theme developers, add the following to the documentation header, at the bottom:
Notes:
At the time the patch is committed, the committer should know what the next release version will be, and can change the {UNKNOWN} to the correct version number.
-------------
I'm not sure about that last one on the new parameter... Just thinking about how we would display this on api.drupal.org. I'm thinking the generic thing would be to turn @since whatever into a line simply saying:
Since whatever
near the top of the page, but this doesn't really work with the "new parameter added" bit. Thoughts/suggestions?
Also, I don't think it will be horrible if for instance webchick changes an {UNKNOWN} to say 7.13, and then it turns out it really should be 7.14 due to a security release. If someone notices, we can make a quick one-line patch later on. But at least we have conveyed the information that this function didn't exist in 7.2 for instance.
Comment #19
tsvenson commentedI'm planning to go over the 7.1-7.12 release notes tomorrow Sunday and create a patch adding the @since for all new functions. I wont add the one for new parameters, but will create a list of all of them so I easily can add them too when we have consensus about it.
As I discovered when testing, see #5, @since will be displayed after @param even if they in the source code comes before. Thus, @jhodgdon proposed template:
* @since New parameter $foo added in Major.pointis needed to make sense in for example Netbeans.
If we will use @since for parameters, then I suggest the following.
For functions:
For Hooks:
That way we get them all in the same place and easily found when reading the source code. The will then also line up nicely in IDE's as well as be easy to parse by for example the API and Coder modules.
I've also filed #1463514: Add support for proposed adding of @since tag to coding standard for the Coder module to alert them about this initiative as well as let them give feedback to help make the coding standard easily parse able.
Comment #20
jhodgdonOK. New proposal for standard:
------------------
For any new hooks, functions, methods, constants, etc. that are added to a branch after the first full release, and that are intended for use by module/theme developers, add the following to the documentation header, at the bottom:
(replace Function with Hook, Constant, etc. if something other than a function was added).
If a function had a new argument added to it, use:
Note that the developer adding the new function, hook, etc. may not know what version their patch will be added to. So, they can use the following syntax:
At the time the patch is committed, the committer should know what the next release version will be, and can change the {UNKNOWN} to the correct version number.
-------------
Comment #21
tsvenson commentedSorry for the delay guys, got a little busy over the weekend. Have started adding @since now and so far done it for 7.1 and 7.2.
I had a short IRC conversation with @jhodgdon about what functions to include or not. Especially since I've discovered much more in just the first point release thant the 5-10 functions estimated for all point releases so far.
The count so far is:
So, basically 23 new functions already in the first point release...
I also stumbled on a few new cases that needs documentation:
When a function moved to a new file:
@since Function moved from [file name]When an argument has changed, but the name is the same:
@since Argument changed from &$foo to $foo in 7.2.I found two of the above change so far.
I've also skipped all .test, .css .install files.
I also partially skipped #1096340: Stale language types/negotation info after enabling/disabling modules. To be precise the part with the locale_test.module as I assume that is part of the test framework and thus don't really need the @since. Correct me if I'm wrong and I will add that in the next patch.
Grateful for a patch review and feedback about if I have added @since in the correct places so I can continue with the remaining point releases up to 7.12.
Comment #22
tsvenson commentedI've already noticed the extra whitespace in the newline before each @since and will remove those.
How to I get "git diff" to not include the .gitignore file itself in the patch?
Comment #23
tim.plunkettShould be $create
I just don't change the .gitignore, if I need to I use a global gitignore file.
Comment #24
dave reidI don't think this is new. I believe $langcode was supported in 7.0 but it just wasn't documented so this does not reflect a functional change?
This is not a necessary @since documentation needed. Objects are passed by reference by default in PHP 5.
Don't think we need to say this now since it's available in the .module file now and not an include.
Comment #25
tsvenson commented@tim.plunkett:
Nice catch, fixed.
So I can just leave the .gitignore stuff in the patch as it is, despite it adding the nbproject folder? Just want to be sure so that folder doesn't end up in core.
@Dave Reid:
$langcode does not exist as an argument in 7.0. It was added in #1089174: Prepare view hooks do not receive the language parameter.
Reason I included the change and moved @since was because they did modify the function calls. I suppose the only two changes possible is either to add or remove the & or that the argument name changes.
For functions moved between files I though it would be good to document it. I know quite a few functions will move in later point releases, such as that big patch for locale when something like ~1,400 lines of code where moved. Probably easier to always use it than have to decide from case to case if its needed or not.
I leave them in for now until we have consensus about what to do about those occurrences.
New patch with above fixes included.
Comment #26
tsvenson commentedGaah, need to remember to change status...
Comment #28
tsvenson commentedNew patch, just added newline to end of .gitignore to see if that is the reason it failed.
If it fails again, please advice me what could be wrong here.
Comment #30
jhodgdonOn your command line, if you do
git diff [files]
you can get a patch that does not include the .gitignore.
You can do git status to see what files have changed, too.
Comment #31
tsvenson commentedOki, after some nice help from the guys in #drupal-gitsupport here is a new patch where I manually have deleted the diff on the .gitignore file. Lets hope this goes through so I can continue adding new point releases.
However, I would like us to agree on how to treat the changed arguments and moved files mentioned in #21 and commented on by Dave Reid in #24.
For move files, I think it would be good to keep a @since trail on them as there will be a few coming up.
Comment #32
tsvenson commentedAnd of course I forgot to change the status again...
Comment #33
jhodgdonOnce again:
This is not really an API change. As someone tried to explain before, the & that had been there was not really doing anything, because $field is an object, and objects are always passed by reference in PHP. So this is unnecessary.
Other than that type of thing, I think the formatting here looks fine.
We still need to get buy-in by the core dev team that they are willing to maintain the practice going forward of adding these @since tags for after-release API additions and changes. And write up the standard and add it to node/1354. And get the API module to support this, which is the easy part.
Comment #34
tsvenson commented@jhodgdon: OK, I'll remove those two changes then and keep the moved file for now. Looks like the test system is happier now after I removed the .gitignore (file was actually cr/lf as well which was probably the main reason it failed).
Going to continue with the remaining now.
Have good some positive feedback to adding @since from people in IRC, so it at least seems like adding this is a popular thing among devs. Now we just need to get the core team aboard also...
Comment #35
tsvenson commentedOki, here is a new patch with the two @since Change removed and also rolled against the current -dev release.
Comment #36
tsvenson commentedNew patch covering all commits up to 7.8. Stumbled on a few new things. Listed below covers everything:
New @since
@since Property added in 7.4.See patch in #42 for #561422: Replace strtr() with str_replace() for db prefixing
However, removed properties not as easy to document since the comment part for it also got deleted. See patch in #69 for #561422: Replace strtr() with str_replace() for db prefixing (same issue as above).
Removed functions can't be documented:
#949616: Multiple parent relations confirmation form loses term description comment #35
#1174444: Make the _element_validate_* functions in field.module available for all contrib modules to use Functions changed from internal to public, incl moved file in the process. Old already marked as deprecated, but not from which version. Treated the public ones as new functions added.
Class function changed and renamed in[#1206200] #20
JS files uses the same syntax as PHP functions.
Skipped .test, .css .install
Comment #37
joachim commentedI feel rather awkward saying this after there's been so much discussion... and so much work on patches :/
But at least with the way my API site is set up, every branch is built from a directory, and that directory is a git checkout. I assume api.d.org uses a git checkout too as a source for the documentation so it can be easily updated.
When I look at a function, it says: "includes/menu.inc, line 1158". That's the line that actually contains the function declaration. So the api module knows the line number already.
So all you'd need to do is stand in the directory of the branch that the function came from and say:
That gives me the commit ID that added that function declaration, as xjm pointed out earlier. I can't see a way to get just the SHA returned, but that's easily plucked out as it's the first 8 characters.
Follow that with:
And that gives me the first tag that contains the commit, with the number of commits between the two. Strip the ~xxx suffix to get just the tag name.
Comment #38
jhodgdonThank you joachim. We should put that on #1456460: Display point release versions on api.drupal.org using the @since tag (I'll go do that now).
Comment #39
tim.plunkettSimilar to joachim, I keep these in my (mac) bashrc:
One shows how many commits this hash is after the previous tag, and the other how many commits are after the hash before the next tag.
Comment #40
jhodgdonI spot checked a couple of things in the patch with joachim's commands. The first few checked out fine. Then I got to:
The result in this case told me the answer was 7.8. So I guess maybe this isn't workable... joachim, any advice on this? I think manual [EDIT]generation of @since tags[/EDIT] may be the only answer.
Comment #41
jhodgdonIn other words, I think that git blame tells you when that particular line in the file adopted its present form (or its present form in the branch you have currently checked out probably?). Meaning that if arguments were added/changed (even just a name change), git blame will point to that commit, not the commit that first introduced the function. Right?
Comment #42
joachim commentedDrat! Curse breakfast optimism! However, I did see something in passing this morning about git log searching for a string.
Here's something, though it was very slow to run!
That shows me when theme_links() was added :)
Comment #43
joachim commentedConsiderably quicker: tell git log to only go as far back as the tag for 7.0:
An empty result means the function existed prior to that.
Comment #44
tsvenson commented@joachim: Welcome to the discussion. The blame approach has been on the table since before I posted this issue. Besides, its been a great exercise for me, learned a ton so no time wasted.
I haven't got as far as to try out blame myself, but from what I seen in the examples in this, and related, discussion, there is always manual steps involved to look up when a function, class, property etc was introduced or changed. Plus that it also requires a git clone of Drupal core to check from.
If that is correct, how can I then easily determine what core version a fairly complex contrib module requires using blame? What kind of setup would I need to be able to automate that?
My hope with proposing to add @since is that, for example, the coder module then can use that information in its review. Since the needed information is always in the code, no git clone is needed, nor any manual work to look up functions etc. Just run the coder review and it tell the core version needed. FYI I filed #1463514: Add support for proposed adding of @since tag to coding standard to get feedback from the coder maintainers about the idea.
Also, I believe the little extra effort it will take to add the @since will also help making it easier to get started developing with Drupal. One less thing to worry about...
Comment #45
jhodgdonWell, it doesn't look like we can really automate everything we need with git, and also drumm posted to #839904: Add "blame" - history of either the function or every line that we should not count on api.drupal.org using git anyway. So, it's back to manual patching.
So.
We have a patch (or at least a start to a patch). We still don't have buy-in that I'm aware of from the key core maintainers that they want this to be a coding standard. The next thing we need to do is agree to the standard. The latest proposal is in comment #20, and as far as I know, no one has agreed to it yet. Thoughts?
Comment #46
tsvenson commentedThere, here is a new patch covering all point releases up to 7.12. Nothing new found other than listed in #36.
The totals for each point release are as followed:
Comment #47
jhodgdonOK, well now we know the scope of the problem -- quite a bit larger than what was being discussed before (I think the estimate was "just a few" changes would need to be documented, and this is definitely more than a few).
So... Here is the path to go forward on this idea:
a) Adopt a documentation standard. Proposal:
------------------
For any new hooks, functions, methods, constants, etc. that are added to a branch after the first full release on that branch, and that are API functions (i.e., intended for use by module/theme developers, meaning any function whose name does not start with an underscore), add the following to the documentation header, at the bottom:
(replace Function with Hook, Constant, etc. if something other than a function was added).
If an API function/method had a new argument added to it after the first full release on that branch, use:
Note that the developer adding the new function, hook, etc. may not know what version their patch will be added to. So, they can use the following syntax:
At the time the patch is committed, the committer should know what the next release version will be, and can change the {UNKNOWN} to the correct version number.
-------------
b) If (a) is adopted by the community, review the patch in #46 in detail to make sure the specific @since tags are appropriate, and get it committed for Drupal 7.
c) If (a) is adopted, get a fix for #1456460: Display point release versions on api.drupal.org using the @since tag into the API module.
I'll put this into the Issue Summary.
Comment #47.0
jhodgdoncreate an issue summary
Comment #48
tsvenson commentedThanks for the excellent summary @jhodgdon.
I did actually add the @since for internal functions (starts with underscore). But once we have an agreement on what will be documented and the exact text template for each case, then I will go over the patch and make the adjustments. Thought it would be much easier to delete if to much than go back and discover what was overlooked.
Comment #49
jhodgdonI think internal (_-start) functions and private methods on classes should not be included. They are not meant to be used by other developers, and are understood to be subject to change. Agreed on your patching strategy though. :)
Anyway, do we have any votes for/against the standard, or suggestions on how to change it? I am agnostic and not voting one way or the other.
Comment #50
tsvenson commentedOki, I've gone through the various since and come up with the following template syntaxes for @since.
Note: The last (removed) will almost excusively be used for arguments as the other types will have all traces of info/doc removed with them.
And yes, the current patch does not reflect the above. I will go over and fix that when/if consensus is reached.
Comment #51
jhodgdonWe need to revive this issue and make a decision.
There is a proposal in #47 (and the issue summary) that every new function/method or new function/method argument added after the 7.0 release will get a @since tag added to its documentation, and that going forward, we would continue to do this throughout the 7.x lifetime (and similarly with 8.x after 8.0 is released, etc.).
As noted in #46 , we are looking at something like 125 @since tags added as of Drupal 7.12. When we started discussing this in IRC, we had thought it was something more on the order of 10 or 20 changes, so this has a much larger scope that was originally anticipated. It also means that probably when we start a new major branch, we should get rid of all existing @since tags... yet another thing on the unwritten (I think) list of how to start a new major branch of Drupal...
So... Any votes up or down on whether we should do this? I am willing for this to be adopted if the branch maintainers are willing to help make sure it happens whenever this type of change goes into a post-release branch. Without this being enforced, it will be spotty and I think much less useful, so my tentative vote is no (but I'm willing to be convinced otherwise if the community thinks the pain of doing it is worth the value we get from having it done, and is committed to making sure it happens).
Comment #52
joachim commentedThat's a lot of manual work to put those in and then take them out of 8.x. I still think the way forward is with automation. Drumm's objection (on #839904: Add "blame" - history of either the function or every line) to having git on api.d.o was:
> And I don't always want API to need Git. Localize.drupal.org grabs tarballs and parses those, which I think good for API parsing more projects.
Which is fair enough -- API module shouldn't *need* git just to run. But couldn't we need git for more advanced fancy features such as this one?
Comment #53
tsvenson commentedI haven't started going over 7.14 yet as I wanted to also go over and clean up what I already have done. We have the proposal in #47, but for me it feels a little limited looking at my findings in #46. That's why I expanded on it a bit in #50.
Comment #54
jhodgdonRE #53 - The first question is whether we want to do this at all -- let's focus on that first.
RE #52 - This issue is about making "since" information available on api.drupal.org. We can't get anything approaching the information in #50 out of git blame in an automated way (right???), and as noted in #52, we can't even count on getting *any* git information on api.drupal.org (even if the API module might theoretically support it), so I think our choice is either do the @since tag or don't have the information available on api.drupal.org.
My feeling is that the @since tag, given that there are so many changes post-release, is hard to maintain, and that if it's not well-adhered-to, it's not going to be worth doing at all. Any other votes on that?
Comment #55
tsvenson commentedI think its very important that we try and look into the crystal ball about the future direction of things in Drupal. At least in the discussions I have seen, there is a broad consensus that Core will need much more ongoing changes/improvements, including new features, in point releases.
Then the question is how can we then improve things to make that happen easier, especially when it comes to compatibility and knowing where things where added. As we seen already the "educated guesses" about 10-20 changes turned out to be a massive underestimate as it was ten times more that that.
Is the @since tag a good way of making it easier to manage these increased changes and feature additions in the future.
As pointed out, its not just api.drupal.org that this is useful. Modules such as coder can also make use of it, automatically advice on the core version compatibility for example. Which then will make it easier to make sure the right core/contrib combo is used.
What alternatives, besides blame, are there? What would those require in comparison.
What happens if we don't implement something like this? Will it make it more difficult to debug for example?
Comment #56
jhodgdonNice framing of the question tsvenson! Too bad I don't have answers... anyone else?
Comment #57
joachim commented> We can't get anything approaching the information in #50 out of git blame in an automated way (right???)
Hmm... that sounds like a challenge ;)
For menu_link_save():
$ git log -S'menu_link_save' 7.0..
Gets me a list of commits that touched that function (could probably do to search more specifically). Pass them to perl and iterate over them...
$ git show f2d2cf8a85df17c6c3bef236a8db147739529259 | grep '^[-+]function menu_link_save'
output is:
That tells me the function args have changed. Now find the tag:
$ git describe --contains f2d2cf8a85df17c6c3bef236a8db147739529259
Says:
I can now tell you that menu_link_save() acquired two params for 7.6.
Now for classes... that's going to be a whole lot harder.
Comment #58
tsvenson commented@joachim I understand that you find blame really useful, and I'm sure it is if I would spend enough time learning how it works etc...
In #44 I asked a few questions regarding just that. I am particularly interested to understand what kind of setup I need to be able to take advantage of this.
What I am particularly interested in better understanding is:
How do I need to setup my local dev environment, incl. do I need git clones of everything, to get this working?
Will it be possible to automate checking the core compatibility for which 7.x version my module requires?
If I understand correct, with the blame approach I need to "manually" query about when something was added. There is no easy way for me to find that out on-the-go so to speak.
Comment #59
joachim commented> How do I need to setup my local dev environment, incl. do I need git clones of everything, to get this working?
Yup. I am issuing those commands in a git clone of core on the 7.x branch.
> Will it be possible to automate checking the core compatibility for which 7.x version my module requires?
Ah I hadn't seen about coder checking stuff... I was working on just showing output on api.d.org. Presumably coder would check every function call in the module it's checking, then check with api.d.org to see when those functions were added (since coder module can't guarantee it has an up to date copy of core locally). If we're outputting machine-friendly data on api.d.org, no reason we can't add stuff we generate rather than just what's in the source.
> If I understand correct, with the blame approach I need to "manually" query about when something was added
I'm not entirely sure what you mean, but I think the answer is 'yes' :)
The way I was seeing this would work is that when api.d.org processes functions to figure out things like the callers, implementations, callbacks, etc, it can also execute the commands to examine the git history and deduce the @since data, and then store that for output. Perhaps I'm on the wrong page here though?
Comment #60
tsvenson commentedThanks for confirming my suspicion. While blame might do the job, it also adds a lot of requirements before it actually can be used. One such thing being the need for local git clonse...
Yes, @since will require some extra work, but it is a one off. Then, when the information is in place it can be used by api.d.o, be visible in IDE's supporting the doxygen markup (Netbeans included) and developer modules such as coder can take advantage of it.
For developers, to use and benefit from this, I believe that is also the important part. Namely that it will just work out-of-the-box (not require git clones) and with tools they most likely already are using.
Comment #61
tsvenson commentedJust noticed Entities now have generic language support that will be introduced in 7.15.
I believe that adds to the argument that we need something that smoothly will aid developers in knowing when API functions where introduced/changed. Especially to better be able to set core version requirements.
Comment #62
jhodgdonI think we all agree that developers occasionally need this information, or rather that the users of their modules might need to know this information (although of course no one should, in principle, be running old versions of Drupal 7.x if a security release has made them obsolete).
What we don't agree upon is whether the burden should be put on the individual developer (use git blame to figure it out) or the core development maintainers and team (use @since to document it).
Given that our policy is that if there is a security release, everyone should be running the latest version anyway, and that nearly all Drupal Core releases are security releases, how much of a problem is this really? I'm more and more inclined to think it's a really large burden on the core dev/maintainer team, and really not a problem for the developer or user as long as they are using the latest version anyway...
Comment #63
sunI'm ok with this, but
- The sentence format is way too verbose. I expect
@since 7.8only.- The previous point inherently means that this won't work for added/removed/changed arguments, which is an acceptable level of detail at which to stop.
- As this is purely historical documentation (and normally our docs in code only document current code) I rather make the compromise between overly verbose @since values and usefulness.
- Speaking of benefits of this, I'm not that excited about potential uses. The only reasonable usage I can see would be by Coder review module. But even that requires relatively complex and possibly longer running code parsing logic to actually leverage this data. For all other use-cases that have been explained to me, I don't see the average module developer Joe take notice of the @since information (and the rather complex core-contrib version dependencies scenario/problem) in the first place.
Comment #64
tsvenson commented@sun: Thanks for you feedback on this, its as always most valuable and much appreciated. Glad to read that you see the benefits this will have for being able to create automatic advising of core compatibility for example the coder module would be able to do if @since is used.
As I mentioned, when (if) we reach consensus on the syntax and what will get this tag I will perform the task on rewriting the existing patch and add all new occurrences that's been added since 7.12 to get the core documentation up-to-date. It should only take me a few hours of work really.
Comment #64.0
tsvenson commentedadd alternative resolution to teach people how to use git
Comment #65
tim.plunkettIs this still relevant?
Comment #66
jhodgdonIt didn't seem to get much momentum. For now closing as Won't Fix. We can reopen later if people want to do it for instance for 8.1.x vs. 8.0.x., but I personally think that api.drupal.org and/or git history will tell us this without manually needing to add an @since tag.