What's the point of that summary line? You could have deduced that from just reading the class name!
Updated: Comment #10

Problem/Motivation

In https://api.drupal.org/api/drupal/core!lib!Drupal!Core!ParamConverter!Pa...
a line reads
"ParamConverterInterface: Interface for parameter converters."
What's the point of that summary line? You could have deduced that from just reading the class name!

Proposed resolution

The description should be improved.

Remaining tasks

Task needs work.

User interface changes

None.

API changes

None.

Original report by joachim

(Text of the original report, for legacy issues whose initial post was not the issue summary. Use rarely.)

Comments

jhodgdon’s picture

Title: [meta] rewrite class summaries that just rehash the class name » ParamConverterInterface one-line description doesn't explain what the class does

I disagree with this meta issue... A well-chosen class name may not need any further one-line documentation that expands on it, and just because the one-line doesn't tell you anything more doesn't necessarily mean it's a bug.

So I'm making this a specific issue for this class, since this doesn't say what type of parameters are converted to what, and definitely it needs more information.

I was going to mark this novice, but since I also have no idea what this interface is for... hopefully someone does!

jhodgdon’s picture

Issue tags: +Novice

Oh, I see on this issue that joachim explains what these parameter converters are for:
#2087107: document routing.yml parameter converters

So probably a novice could come up with a good patch for this.

rickwelch’s picture

Assigned: Unassigned » rickwelch

Working on this at Drupal Camp Costa Rica.

rickwelch’s picture

Status: Active » Needs review
StatusFileSize
new521 bytes

Added small long description.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks for the patch -- good start!

So... I think we want to replace the existing first-line docs for this interface with documentation that actually gives us some information -- assuming we can do that in one 80-character line. Maybe, taking what you wrote, it could be:

Defines an interface for converting route parameters to classes.

[note that you misspelled classsed in your patch]

Then in a second paragraph, we can expand that information to explain what "parameters" mean in this case, and how/why they are converted to classes. I still am not sure what that means actually... and maybe this isn't such a great Novice project? Well, maybe you know more than I do, or maybe you can get help from someone in IRC with understanding it?

Crell’s picture

I was actually sitting next to Rick as he wrote this patch at an impromptu DrupalCamp CR new contributors sprint. :-) I like Jen's suggestion for improving the short description, and then just fixing up the spelling in the long description. (Explaining what a route parameter is is out of scope for this docblock, IMO.)

Rick, can you update the patch?

joachim’s picture

My intention with #2087107: document routing.yml parameter converters was that this interface should be the documentation entry-point to the concept of parameter substitution in routing:

- it could be linked to from an eventual topic on @routing
- api.d.o already lists the class that implement the interface, so there is an automatic linkage to the things that do actual subs, which themselves can have more in-depth docs along with examples.

This way we get docs that are nicely navigable, AND keep the docs text close to the code.

> (Explaining what a route parameter is is out of scope for this docblock, IMO.)

Where would you put it?

Crell’s picture

Where would you put it?

In some d.o-based documentation on the routing system. Why should we spread routing system documentation all over the code base? How would you know which of our 1000+ classes to look at for a detailed explanation of implementation details of 3 different systems interacting?

Besides, "implementation details" do not belong on an interface anyway. :-)

joachim’s picture

> In some d.o-based documentation on the routing system

I'm suggesting that too: start with d.org pages and/or a @topic. Then link through to docs on this interface to explain the general process of taking values

> Why should we spread routing system documentation all over the code base

Keeping the docs close to the code is a good way of ensuring they stay in close sync -- isn't that the point of our having docs in code?

> Besides, "implementation details" do not belong on an interface anyway. :-)

I wasn't suggesting we put implementing details here, but an explanation of what implementing the interface allows classes to do.

Here's roughly what I'm suggesting:

Routing topic
=========

The routing system allows modules to define yada yada. Routes are defined in yaml files yada yada. In your route, you can use magic parameters to upcast ids in the path to full objects: @see ParamConverterInterface for further details.

ParamConverterInterface
================

The ParamConverterInterface is used to handle upcasting of ids to full objects. More on the magic of this here, as I'm currently stumped by it. For instance, do I have to declare something in my route, or can just use {entity_type} as a piece of my route path? I suspect it's the former, as I'm doing the latter in my module and it's not working.

Different implementations of this interface provide different parameter conversions.

EntityConverter
===========

Converts entity ids to full entities. Use the entity type as the magic path component. Examples:

This creates documentation that's close to the code, and is also easy to follow through a short pathway of links on api.d.o.

PavanL’s picture

Issue summary: View changes

Added issue summary template.

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new1.3 KB
new1.39 KB

Rather amazed to find that #4 still applies.

Changed the docblock to look like this:

/**
 * Interface for parameter converters.
 *
 * Classes implementing this interface are responsible for converting a path
 * parameter to the object it represents.
 *
 * Here is an example path:
 * @code
 * /admin/structure/block/manage/{block}
 * @endcode
 * In this case, 'block' would be the path parameter which should be turned into
 * the block in question for administration.
 *
 * @see menu
 */

Also some action-verb changes to the method docblocks.

There isn't a routing topic on api.drupal.org, but there is @menu which is 'menu and routing,' which punts to Symfony documentation wrt routing.

Status: Needs review » Needs work

The last submitted patch, 11: 2087103_11.patch, failed testing.

mile23’s picture

Not sure why SimpleTestBrowserTest is unhappy with my docblock changes, but there you go.

Crell’s picture

  1. +++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
    @@ -11,11 +11,23 @@
    + * In this case, 'block' would be the path parameter which should be turned into
    + * the block in question for administration.
    

    "block object". Or ideally, specify the class name of the object. Returning a stdClass would be an error.

  2. +++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
    @@ -11,11 +11,23 @@
    +   * Convert path variables to their corresponding objects.
    

    ConvertS

  3. +++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
    @@ -32,7 +44,7 @@
    +   * Determine if the converter applies to a specific route and variable.
    

    DetermineS

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new1.22 KB
new1.49 KB

Thanks.

For #1, it's an interface so saying {block} always returns a specific class isn't the way to go. Also, I just learned a bunch more about ParamConverters, that they're services, and that they're managed by a central service. So woot. :-)

#2 and #3: Nice.

/**
 * Interface for parameter converters.
 *
 * Classes implementing this interface are responsible for converting a path
 * parameter to the object it represents.
 *
 * Here is an example path:
 * @code
 * /admin/structure/block/manage/{block}
 * @endcode
 * In this case, '{block}' would be the path parameter which should be turned
 * into a block object representing the block in question.
 *
 * ParamConverters are defined as services tagged with 'paramconverter', and are
 * managed by the 'paramconverter_manager' service.
 *
 * @see menu
 * @see \Drupal\Core\ParamConverter\ParamConverterManagerInterface
 * @see \Drupal\Core\ParamConverter\EntityConverter
 */
jhodgdon’s picture

Status: Needs review » Needs work

Looks good to me! One minor nitpick:

+++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php
@@ -11,11 +11,28 @@
+ * Here is an example path:
+ * @code
+ * /admin/structure/block/manage/{block}
+ * @endcode
+ * In this case, '{block}' would be the path parameter which should be turned

This should not be in a @code block, I think?

mile23’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
new765 bytes

Done.

Crell’s picture

Assigned: rickwelch » Unassigned
Status: Needs review » Reviewed & tested by the community

OK let's do. Thanks!

xjm’s picture

Status: Reviewed & tested by the community » Fixed

This is so much better than before. Well done!

This issue only changes documentation, so per https://www.drupal.org/core/beta-changes, this can be completed any time during the Drupal 8 beta phase. Committed and pushed to 8.0.x, thanks!

  • xjm committed 8df466d on 8.0.x
    Issue #2087103 by Mile23, rickwelch, jhodgdon, Crell, joachim:...

Status: Fixed » Closed (fixed)

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