We're getting so many examples it's going to be hard to navigate.

I think we need:

  • A main landing point (an 'examples' module?) that provides text. If people enable 'examples' then they have text at /examples that gets them started. It also can have some PHPDoc code that will link to the other examples, perhaps enhancing the index.php at contributions/docs/developer.
  • A defined organization for menu entries and paths.
  • A standardized presentation. For example, the Form example tutorial now has 10 tabs, for the 10 examples. That would probably improve the AJAX example as well.

My idea is that every example should be discoverable both by browsing the code and by enabling the module and exploring it.

Comments

rfay’s picture

In addition, I think a docs section would be good - a set of pages explaining what each module is about

johnalbin’s picture

Since we're now including the examples module in the api.drupal.org docs, we desperately need a Table of Contents or something to make it easy to navigate all of the examples in this project.

Then the docs at contributions/docs/developer can point to the index page included with this project.

johnalbin’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB

Here's a patch that moves the links from developer/index.php into an examples.index.php.

Once this is in, we can modify the developer/index.php to just use this syntax to link to this module's examples.index.php file.

@link examples.index.php Example modules @endlink
rfay’s picture

Status: Needs review » Needs work

Works for me. Committed to CVS HEAD. http://drupal.org/cvs?commit=365672

Thanks for your contribution here and in the other issue as well.

Still lots of work to do on this issue, so leaving "Needs work"

rstamm’s picture

StatusFileSize
new4.22 KB

a base module is a good idea which provides a main landing page (text and list of enabled example modules) and maybe some base functionalities for the example modules, such as a main menu entry and main permission.

patch is an example for a base module.

dave reid’s picture

We can probably scan module files and their .info properties for example modules instead of relying on a new hook, which might confuse people using these examples as base code.

rfay’s picture

@davereid, I agree: We want to keep the examples as lean as possible, focusing on communicating about the API at hand, and not introduce new ones just to make this module itself work well.

I'd rather have a static list of module entry points (that got updated when new things were added) than something that adds a hook. I don't think it would be too hard.

Scanning the info files would be OK; not sure we actually have to do that work.

codewaggle’s picture

Where is "contributions/docs/developer" located?

I tried "http://drupal.org/contributions/docs/developer" and got "Page not found".

rfay’s picture

@codewaggle, it's in CVS, so cvs.drupal.org/cvs/contributions/docs/developer

Currently, examples gets checked out into that neighborhood so that API module can index it.

codewaggle’s picture

@rfay, Thanks.

Looks like the paths have been changed a bit, but this pointed me in the right direction.

cvs.drupal.org/cvs/contributions/docs/developer
was redirected to
http://drupalcode.org/cvs/contributions/docs/developer (404 error)

I tried
http://drupalcode.org/
and was redirected to
http://drupalcode.org/viewvc/drupal/

The contributions folder is listed there.

rstamm’s picture

ya, to keep the base module more simple and examples without the special hook is better. we can add a separate custom hook example later.

examples getting more and more with the time, maybe it's good the if the base module provides a separate examples menu block like the devel module.

ilo’s picture

just as a reminder: I'm starting to have the feeling the we should sepparate in some way core/api examples than other 'features' examples like token, or any of the features awaiting in the issue queue..

rfay’s picture

IMO as a general rule no contrib features should go into Examples. I am *way* into using or creating other projects. The only two exceptions to this are VT and Token, which have exact analogs in D7.

I don't even want a CCK field example in here, but would love to create another project for that.

Examples is for core features. Have to draw the line somewhere :-)

ilo’s picture

what if these non-core examples go to a documentation page in the corresponding project documentation page (so it must exists)? cck, ctools, there are a few in the issue queue as features to be included into examples.

rfay’s picture

IMO examples should go into projects where they can be maintained, as this project has amply demonstrated. It's just that non-core can't go here. But it's easy enough to create new projects. There *is* a views_example project, and I so dearly want API examples to go into that, and I think the maintainer is open to it. I would hope for other examples of the type. And we could certainly link to them. And then eventually we'll get an "example" taxonomy term for projects.

ilo’s picture

That is a good idea, +1!.

On the other hand, about organizing this project:

Examples integration in api.drupal.org for D6 and D7 are different:
- D6 shows a list of links, each link pointing to an example module
- D7 shows a single link to an additional page.

Just testing, I've found extremelly dificult to reach the "examples" project navigating the documentation section of d.o. I had to click several links until I finally found the api.drupal.org link.

I agree with rfay at #1 that we may introduce a documentation page describing what each example module does, and link that page at: http://drupal.org/developing/modules . Other possible place where a link to that documentation page makes sense is here: http://drupal.org/node/326 (Working with the Drupal API)

You know, my english is not the best, I'm spanish, so.. anybody wants to review/rewrite it if I do write that documentation page?

rfay’s picture

Actually, we're in charge of the initial link; it's just edited via CVS. It just hasn't been properly handled. And we should have a basic landing page as part of this module that's maintained here.

I think we should probably have a root "examples" module that just turns on the /examples menu router item and explains what this is all about. And it could/should have a more informative landing page built in for API.d.o.

mile23’s picture

I give you: http://api.drupal.org/api/examples/6

http://api.drupal.org/api/drupal doesn't have a direct link to examples. Also, I think it would be better for the main API page to simply link to the top Examples group as one item, rather than try to link to all the individual modules. Given the evolving nature of these docs, it's less work at that level.

The real problem is that Drupal doxygen brings all the groups up to the front page, ignoring the heirarchy. So if the canonical link is /api/examples, it gives you the main examples group and all the subgroups in a big long list. Confusing. But it gives links so you can browse the files and functions and constants, which is probably valuable.

I don't mind bombing through a bunch of this doxygen commenting task, but I want to be going in the right direction. Anyone see any other problems with the way the D6 examples API page is going?

mile23’s picture

Hah. Meant to post the comment on this thread: #767204: API.drupal.org: Rework Doxygen comments so people can navigate the comments

But I guess it still works here.

mile23’s picture

StatusFileSize
new7.46 KB

I made an .info and .module file for D7, and removed the .index.php file. Eventually we patch against core for a link from api.drupal.org, for the examples group.

This can be a basic template for how sub-modules can document themselves.

dashohoxha’s picture

Version: » 7.x-1.x-dev
Category: task » feature

I think that for a beginner to Drupal (as I am) it is a bit difficult to find the way around the examples. It is not so clear which example to study first and which later. After looking at some of them, it became clear to me that there are some prerequisites (dependencies), although each of the examples is supposed to be stand-alone. For example menus are used in almost all examples, so it could be better if menu_example is studied first.

There may be other dependencies like this as well. It might be a good idea if these dependencies are somehow documented. Or it may be even better if there is a suggested order of studying the examples.

mile23’s picture

I'm calling this closed. Most of the ideas raised here have been implemented for 7.x and moving forward to 8.x.

We currently have #2209627: [meta] Module Checklist for Examples for contributors, and #1007276: [policy, no patch] Comaintainer practices and procedures for co-maintainers.

Status: Fixed » Closed (fixed)

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