It's way cool having the examples on api.d.o, but we need to figure out a way for people to find their way to a larger chunk of example, or the specific file that is the most interesting. Mostly they don't need to see some small form constructor function in isolation.

How can we do this well?

Comments

cyberswat’s picture

StatusFileSize
new965 bytes

Maybe we simply need to rework the comments so that they work really well being displayed on the api site. I think it is a little misleading and possibly confusing for newer developers to see those examples without a clear reference to all of the pieces that make them work. I have to admit that I'm not familiar enough with phpdoc but it looks like a change in wording and appropriate use of the @see or @link tag is the way to go. Here's a super quick patch that might help with node_example.

cyberswat’s picture

Status: Active » Needs review
rfay’s picture

I think we're going to need more than this, on all the examples. In the next comment I'll try to write up a bigger list of what I think needs to be done. This is a decent start though - just adding the referral to the install should work.

(I'm not sure whether @see on a file will work)

+++ node_example/node_example.module	10 Apr 2010 02:56:04 -0000
@@ -3,6 +3,9 @@
+ * It is importnat to note that the majority of the functionality for the

important

Powered by Dreditor.

rfay’s picture

Here's a braindump of what I'm thinking after looking at lots of the examples on api.drupal.org.

1. To be successful working with the doxygen comments, you'll need to set up the API module. Lately this hasn't been too hard, but you need to use the dev versions of api and grammar_parser. Set up using the instructions at http://drupal.org/node/425944. When you have an API site set up, you can just run cron and immediately see the result of your doxygen.

2. Every example group docblock should have at the bottom something like "This example is part of the @link http://drupal.org/project/examples Examples for Developers Project @endlink which you can download and experiment with.

3. Groups are going to be the way that people find their way to the entire example, grouped together. If you take a look at the AJAX Example, which seems to be working the best this way, It has a main group:

http://api.drupal.org/api/group/ajax_examples/7

That lists each of the examples. Then each of those, for example,

http://api.drupal.org/api/function/ajax_example_autocheckboxes/7

shows up in a description and has its own page.

This is done with @defgroup and @ingroup, as you'll see in the AJAX examples.

Doxygen documentation is at http://drupal.org/node/1354.

4. Example groups should be

@defgroup ajax_example Examples: AJAX {

Individual examples should be in a group named like

@defgroup ajax_example_simplest Examples: AJAX - Simplest {

5. We need a master group (Examples) that will be in a main examples.module. The examples.module should be mostly doxy comments that point to the other examples. It will also have a hook_help() explaining its purpose and how to access the other examples.

6. Each example or group should link to its parent group with @ingroup. For example:

@ingroup parent group
@ingroup examples

7. This is a work in progress. We'll have to make some changes when we see how the api docs come out. Let's make sure we get one module correct before proceding. I think the form example is a good place to start. It has 10 examples in two groups (so far).

[Edit: I changed the above a bit based on feedback from jhodgdon.]

jhodgdon’s picture

Status: Needs review » Needs work

A couple of comments:

#3: @see on a file should work. If it doesn't, that's a bug in the API module.

#4:
item 2 - I think having a link to the Examples project is a great idea. But I think the link text being "Example module" is not great. How about just
This example is part of the @link http://drupal.org/project/examples Examples for Developers project @endlink.
(not sure if putting . right after @endlink screws it up?)

item 3 - Making a group for each example will greatly add to the already too big list of topics on api.drupal.org. If you are set on doing this, at least maybe you can start the human-readable group names all with "Example", so they'll sort together in alphabetical order on the topics list?
http://api.drupal.org/api/groups/7
Check out the hints section here about not adding too many topics:
http://drupal.org/node/1354#hints

rfay’s picture

I edited #4 to reflect all of jhodgdon's concerns (I think). We talked in IRC and she's reluctantly OK with having lots of new groups.

rfay’s picture

Title: API.drupal.org: Figure out how to get people to the right file or section » API.drupal.org: Rework Doxygen comments so people can navigate the comments
Status: Needs work » Needs review
StatusFileSize
new24.14 KB

Here's a first pass at some cleanup on the D7 Form Example. I think the generated docs come out OK. If it passes the bot, I'll commit it and everybody can peruse the results and see if they like them.

rfay’s picture

HEAD still broken, so I went ahead and committed this one: http://drupal.org/cvs?commit=353976

We'll see what API.d.o looks like in the morning and whether we like it or not.

Status: Needs review » Needs work

The last submitted patch, examples.form_example_cleanup_767204_07.patch, failed testing.

rfay’s picture

OK, here's what the D7 Form example looks like after the rework of doxy blocks:

http://api.drupal.org/api/group/form_example/7

Please browse around the 11 examples in the form_example module and see if you think it works.

I didn't make groups for each example. Instead, I just made sure that there were proper @see's in each function.

BTW: HEAD is fixed now.

jhodgdon’s picture

I'm not sure why the main form example page needs two links to the same project page -- it was a bit confusing to me on first quick scan, because their link text is different. But that's very minor.

I also thought maybe you could rename the example functions form_example_tutorial_01, 02, etc. so that 10 would come after them in alphabetical order. Again, very minor.

Other than that, it seems fine to me.

rfay’s picture

Status: Needs work » Needs review
StatusFileSize
new32.71 KB

Here's another pass. This addresses the comments in #11. Just by happenstance I deleted a test (#8) so that will help the ordering.

The most important change in this patch though is that #8 and #9 (the add-more and multistep examples) have been significantly reworked again, per advice from @effulgentsia. Although they're not as general as a real form would be (maybe #8 is) the intent is to show the mechanism.

rfay’s picture

Committed to HEAD: http://drupal.org/cvs?commit=355264

This will probably need to be backported to the D6 version of the form examples.

rfay’s picture

Status: Needs review » Active
mile23’s picture

I did this for D6. (Insomnia. Woot.) Added lots and lots of doxygen tags to the various modules, with only minimal editing of the actual documentation.

Shall I put the patch here or make another issue?

rfay’s picture

Version: » 6.x-1.x-dev

Yippee! Go ahead and put it here. There seems to be a never-ending amount of this work, as this project increased in scope much more than we thought.

#4 is the roadmap for what we want to accomplish. There's plenty of work left to do on that in both D7 and D6.

Thanks!

mile23’s picture

Status: Active » Needs review
StatusFileSize
new19.2 KB

Clearly the actual documentation content is somewhat incomplete. Also, I only added a stub hook_help() in examples.module.

Status: Needs review » Needs work

The last submitted patch, d6-examples-doxygen.patch, failed testing.

rfay’s picture

In http://qa.drupal.org/pifr/test/114534, open up the "review log" fieldset to see the patch apply failures. I get the same failures when applying locally. It looks like you might have started with an older version (and didn't pick up the xmlrpc changes that went in on 13 Dec)

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new19.67 KB

Yes, the joke's on me. On the other hand, I can now endorse DiffMerge for Mac as a useful tool.

rfay’s picture

Status: Needs review » Fixed

Committed, with one small change in page_example (where the hook_help() had been removed).
http://drupal.org/cvs?commit=470470

Thanks so much!

rfay’s picture

Status: Fixed » Needs work

Now, for onward and forward.

@Mile23,

* if you could review the api.drupal.org results with after it gets rebuilt (tomorrow or later)
* Then D7, right?
* Also we can continue this with many other "how to navigate issues" with Examples. Probably, though, when we get api.d.o working the way we want, we can do the other things in other issues.

Thanks!

ilo’s picture

Thank you both so much for this commit!

mile23’s picture

Rawk. :-)

I have a local drupal install that has API, and that's how I was learning doxygen testing the output.

mile23’s picture

mile23’s picture

Version: 6.x-1.x-dev »
Assigned: Unassigned » mile23

OK, so I guess I'll bomb forward on the D7 examples, in the same pattern as the D6 ones.

mile23’s picture

Assigned: mile23 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new74.28 KB

Added a lot of doxygen to most of the D7 part of Examples. A few exceptions: I left out nodeapi and node_access because of various discussions about their appropriateness: #1028162: Review Node Access example in light of ch 9 of Drupal 7 Module Development #947334: Node access example comment; Improve discussion of grants #1015846: Module should not delete fields on uninstall

Also, I wasn't very thorough with reworking the documentation itself, just the format. So some modules suffer a bit because of this.

Status: Needs review » Needs work

The last submitted patch, d7_examples_module_767204.patch, failed testing.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new90.43 KB

Hmm... How did vertical_tabs_example.js end up with CRLF line endings? :-) Helpful hints here: http://help.github.com/dealing-with-lineendings/

Status: Needs review » Needs work

The last submitted patch, d7_examples_module_lf_767204.patch, failed testing.

rfay’s picture

Status: Needs work » Needs review

#29: d7_examples_module_lf_767204.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, d7_examples_module_lf_767204.patch, failed testing.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new90.42 KB

Note to self: Run The Tests Locally First. :-) Also: Yay agile!

Status: Needs review » Needs work

The last submitted patch, d7_examples_module_wtf_767204.patch, failed testing.

mile23’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, d7_examples_module_wtf_767204.patch, failed testing.

mile23’s picture

Status: Needs work » Needs review
mile23’s picture

You know... It was a lot of work. :-)

rfay’s picture

And very much appreciated.

I apologize that I've been out of service. Trying to focus on the Git migration and just ignoring this queue. But we'll get your application approved and we should be good to get things committed more often.

dave reid’s picture

Version: » 7.x-1.x-dev
mile23’s picture

Assigned: Unassigned » mile23

I'll come back to this in the next week unless someone objects. :-)

tr’s picture

@Mile23: That would be fantastic. I'd like to get this put in as soon as possible. The patch needs to be re-rolled against the latest head - there are a bunch of small changes that already got fixed that now conflict with the same small changes you make in your patch. I actually started to port the patch, and if you don't mind I'll finish that up this weekend and post it, then let you check to make sure I didn't mangle any of your work.

mile23’s picture

OK, sounds good. :-)

mile23’s picture

Assigned: mile23 » tr
tr’s picture

StatusFileSize
new127.21 KB

Here's a new version of the patch rebased to the current head of 7.x-1.x. I added a lot of minor changes to the doxygen comments to conform to the style guidelines, but there's still a lot to to. I don't think it all needs to be done in this issue.

mile23’s picture

StatusFileSize
new128.09 KB

Looks good. Coder gave me some hiccups so here's yet another patch. :-)

Most of the doxy framework is there in my old patch. Specific formatting can be done in their own issues as people find them. I think it's more important to get the doxy committed at this point, so api.drupal.org can trawl them. After that, core patch time to link to it correctly, and people can start patching the egregious errors they find.

Then it's on to #761334: Organize Examples in a way that the whole project can be understood :-)

Status: Needs review » Needs work

The last submitted patch, doxy_more_767204.patch, failed testing.

tr’s picture

@Mile23: It looks like your patch is reversed.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new128.12 KB

Lesson: One coffee not enough.

rfay’s picture

StatusFileSize
new126.51 KB

So sorry I've been so delinquent on this.

Here's a reroll, which fixes a couple of whitespace issues and removes the CHANGELOG.txt's that were still surviving.

If this survives the testbot please look at it quickly and let's get it in before it kills us. Thanks for all the great work on this, @Mile23 et al.

rfay’s picture

Priority: Normal » Critical
rfay’s picture

Status: Needs review » Fixed

OK, I committed this, but without the changes to node_access_example.module, because it had a thorough going-over in #947334: Node access example comment; Improve discussion of grants (and there were lots of conflicts)

But here we go!

D7: e652b54
D8: 39ddf0d

Thanks so much for all the wonderful work on this, @Mile23. So sorry it got stuck. Mea culpa.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mile23’s picture

Oo... Thanks rfay. I should log in to d.o more often. :-)

mile23’s picture

Assigned: tr » Unassigned
Status: Closed (fixed) » Needs review
StatusFileSize
new3.82 KB

Missed one.... Good old nodeapi_example. :-)

This might crash up against #1115944: Variables aren't cleaned up on uninstall.

tr’s picture

Patch in #50 introduced D7 code into the D8 branch. Fixed in commit c0f027551980.

rfay’s picture

Thanks TR.

rfay’s picture

Status: Needs review » Fixed

Committed: #55: dc2b847

Sorry, I had missed that this one was hanging out.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.