This issue attempts to extend the help and on-site documentation for the Rules project in the following ways:

* Adding "configure" links in the modules list for Rules and Rules Scheduler. (done)
* Adding and improving a number of description texts in the Rules UI. (done)
* Providing a way to manage links to drupal.org docs pages in one central place in the code. (partly done)
* Adding a help page for Rules, as used by the Help module, containing all the links used in inline help. (done)

The current stumbling block is where to place the function rules_external_help(), used for collecting urls for external help pages (as well as the list of all such links).

The function is currently placed in ui.forms.inc, which means that it is available at all places where UI is shown. However, this file is not included when running SimpleTests, making the tests for this issue to fail.

A possible solution is to let the SimpleTests include ui.forms.inc – but there are probably better ways of doing this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Itangalo’s picture

Component: User Interface » User interface
Status: Postponed (maintainer needs more info) » Postponed

I just had the greatest idea – I can implement this as a separate module, and if it works well then it could be merged into the Rules project. Damn, I'm so smart. :-P

fago’s picture

Status: Postponed » Active

I like the idea, though I don't think we should make an on/off option for the help. Ideally, would be always there and just one click away. E.g. it could be hidden by JS by default.

Still, we can surely add more help that is just visible by default. If its not longer than 2,3 sentences it should be fine.

Let's ping klausi about that.

fago’s picture

New proposal:
Itangalo, So let's add more visible help (2-3 sentences) including points to the handbook for the advanced help?

klausi’s picture

I also think that the extensive help should be in the handbook pages. Adding some explanations here and there sounds good to me, but we should always link to the handbook pages. We could also hide the help in a javascript fieldset or behind a help symbol, if we think it clutters the page.

I don't think we should add links to screencasts in code, instead we could maybe create a Rules screencast learning page in the handbooks. Handbooks are easier to edit for people that are not familiar with the patch workflow.

Itangalo’s picture

Status: Active » Needs review
FileSize
16.08 KB

Allright!

Attached is a (sadly) big patch, that does the following:

1) Adds configuration links to the modules list. This is done only if Rules UI is enabled.
2) Adds heaps of descriptions and help texts. Most of these are 1–2 sentences and then a link to some page on Drupal.org.
3) Adds a help page for Rules. (Again, only available if Rules UI is enabled.) The help page states that documentation is kept online, and then lists all the pages used in the description texts (along with some labels).

TODO:
* For Rules maintainers: See if you think this is a good approach for descriptions/inline help.
* For me: Create/update the relevant documentation pages on Drupal.org, and then update the links in the descriptions.

Itangalo’s picture

Ok, new patch!

Updates from previous one:

* The helper function for keeping track of external docs pages is now moved to rules_admin.module (instead of rules_admin.inc). This is bad from a performance point of view, but good since it makes it possible to use it at all places where we refer to external docs.
* The helper function now contains all the data for the external pages, which makes it easier to maintain them and also makes it much neater to build the on-site help page.

NOTE 1:
I am not 100% sure that rules_admin is loaded at all places where the Rules user interface may try to call rules_admin_external_help(). With Rules core, the interface is only called from rules_admin (as far as I know), but other modules may implement other user interfaces. With rules_admin turned off, this would give fatal errors.
Any good ideas on how to manage this?

NOTE 2:
The previous patch passed all tests. Yay!

Status: Needs review » Needs work

The last submitted patch, 1297414-6-lots_of_help_for_rules.patch, failed testing.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
16.21 KB

New patch. Just minor updates to the helper function (such as pushing URLs through url() before returning them).

I think the test fails above are caused by what I describe in note 1 above. One possible solution would be to actually add the helper function into rules.module, but that seems pretty heavy to me.

Status: Needs review » Needs work

The last submitted patch, 1297414-8-lots_of_help_for_rules.patch, failed testing.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
18.51 KB

For testing purposes, I tried moving the helper function to rules.rules.inc, instead of rules_admin. Let's see what the bot thinks.

Itangalo’s picture

/me scores. :-)

Itangalo’s picture

Sigh. Seems some files weren't saved, so here's a new patch. Learning every day.

Itangalo’s picture

Dammit – now another include is run for the help page.

fago’s picture

Status: Needs review » Needs work
+++ b/includes/rules.plugins.inc
@@ -542,7 +542,10 @@ class RulesLoop extends RulesActionContainer {
+      'description' => t('The list to loop over. The loop will step through each
+        item in the list, allowing further actions on them. See <a href="@url">
+        the online handbook</a> for more information on how to use loops.',
+        array('@url' => rules_external_help('loops'))),

Coding style says we should not add line breaks here. Just make a loooong line, editors can still break it for users.

+++ b/modules/system.eval.inc
@@ -195,6 +195,12 @@ class RulesTokenEvaluator extends RulesDataInputEvaluator {
+      '#description' => t('Note that tokens containing chained objects – such as

Let's call them "token replacements" not just tokens, because token == replacement is drupalism.

+++ b/modules/system.eval.inc
@@ -195,6 +195,12 @@ class RulesTokenEvaluator extends RulesDataInputEvaluator {
+        <em>data selection</em> input mode may help you find more complex

Yep, that sucks though is the best way to do it by now.
We should find a way to go with the token.module ui.

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+ *   The key for a given topic. If given, the return will be the URL for the
+ *   topic online help. If omitted, the full array of external help pages will

It suffices to document this for @return once. $topic should be marked as " (optional) The key ..

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+ *   be returned.
+ * @return

We should add a new line before return. I know it's violated in rules too, but let's start doing it right.

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+      'url' => 'http://drupal.org/data-selection',

Can we do such nice urls? :D

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+      'label' => t('Using complex tokens/replacement patterns'),

Let's say "token replacement patterns" ?

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+    return url($help[$topic]['url']);

Why do we specify a label if we don't return it.

+++ b/rules.rules.inc
@@ -107,3 +107,68 @@ function rules_rules_evaluator_info() {
+  elseif (!is_null($topic)) {

Just use isset(), that's preferred to is_null.

+++ b/rules_admin/rules_admin.inc
@@ -29,6 +29,19 @@ function rules_admin_reaction_overview($form, &$form_state, $base_path) {
+    '#markup' => t('Reaction rules, listed below, reacts on selected events on

rules *react*

+++ b/rules_admin/rules_admin.inc
@@ -29,6 +29,19 @@ function rules_admin_reaction_overview($form, &$form_state, $base_path) {
+      may have any number of <em>conditions</em> that muste be met to execute

typo: muste

+++ b/rules_admin/rules_admin.inc
@@ -29,6 +29,19 @@ function rules_admin_reaction_overview($form, &$form_state, $base_path) {
+      these actions. You can also set up <a href="@url1">components</a> –

that must be met to fire the rule?
or
"that must be met for the actions to be executed"

+++ b/rules_admin/rules_admin.inc
@@ -95,6 +108,16 @@ function rules_admin_components_overview($form, &$form_state, $base_path) {
+      multiple places. You may also export each component separately. See

... and call it from your custom module? Is that of interest?

+++ b/rules_admin/rules_admin.module
@@ -90,6 +90,38 @@ function rules_admin_menu() {
+function rules_help($path, $arg) {

Why not just use rules_admin_help() ?

+++ b/rules_admin/rules_admin.module
@@ -90,6 +90,38 @@ function rules_admin_menu() {
+    include_once drupal_get_path('module', 'rules') . '/rules.rules.inc';

IT doesn't really fit in rules.rules.inc. Let's move it into ui/ui.forms.inc ?

That should be included every time the UI is used, we just have to include it here then.

+++ b/rules_admin/rules_admin.module
@@ -103,3 +135,19 @@ function rules_admin_form_alter(&$form, &$form_state, $form_id) {
+  if ($file->name == 'rules') {
+    $info['configure'] = 'admin/config/workflow/rules';
+  }

Oh that's nice - great idea!

+++ b/rules_scheduler/rules_scheduler.rules.inc
@@ -149,7 +151,13 @@ function rules_scheduler_action_schedule_validate(RulesPlugin $element) {
+    sure cron is configured correctly by checking your site\'s !status. The

There shouldl be no \' in t(). Use "" instead of ' and you can just go with "'".

+++ b/ui/ui.data.inc
@@ -65,6 +65,12 @@ class RulesDataUI {
+        available to Rules. <em>Note that entity fields will only be available
+        if you have used the condition \'entity has field\' (or \'content is of

Hm, that's not generally true. E.g. user account fields are always there, as there are no bundles. So maybe say if there are bundle-specific fields.. ?

+++ b/ui/ui.plugins.inc
@@ -180,7 +180,8 @@ class RulesLoopUI extends RulesActionContainerUI {
+      '#description' => t('The variable used for holding the each list item

the each..

Itangalo’s picture

Great feedback! Learning a lot from reading it. Looking forward to updating the code.

Some feedback on the feedback:

> Can we do such nice urls? :D (http://drupal.org/data-selection)
Nope, we can't. :-( I'm gonna update them all to relevant urls before the patch is complete.

> Why do we specify a label if we don't return it. (for the rules_external_help function)
The labels are used on the Rules help page. In a previous patch I had the help function add all the labels, but it seems much better to have them declared at the same place as the urls.

> ... and call it from your custom module? Is that of interest? (concerning components)
Yes! Good point.

> Why not just use rules_admin_help() ?
Because then the help topic will show up as "Rules UI" instead of "Rules", which I thought was bad.

fago’s picture

>Because then the help topic will show up as "Rules UI" instead of "Rules", which I thought was bad.
I see, then we should comment that. :)

>The labels are used on the Rules help page. In a previous patch I had the help function add all the labels, but it seems much better to have them declared at the same place as the urls.
Oh, I see.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
16.14 KB

Attached is the patch, with comments above fixed. :-)

Two notes:
* In the really loooong t() texts, I have placed the array with replacement patterns on a line of its own. I'm not 100% that this is according to coding standards, but it will make it easier to read and also won't put line breaks into the actual t() text.
* A few of the t() texts previous wrapped with ' had links in them – where the url was wrapped with ". Since the t() text is now wrapped with ", I have changed the url wrapping to '. (I think this is against the recommended best practices, but it makes the code easier to read and avoids using \".)

I also noticed that the help page got a fatal error, which is now fixed. I think this is the only place where rules_external_help() outside the UI, so it should be allright now.

Also, all links now point to the right pages online. We could (and maybe should) add more pages to list on the help page – even if they are not used in the inline help – but I think that could be done later.

This means, that if the patch feels ok, it should be ready to go in. Yeah!

Status: Needs review » Needs work

The last submitted patch, 1297414-17-lots_of_help_stuff.patch, failed testing.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
16.14 KB

Found one miss in the rules_external_help function, now corrected. Can't see why it should cause the error above, so we'll see how this works…

Status: Needs review » Needs work

The last submitted patch, 1297414-19-lots_of_help_stuff.patch, failed testing.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
16.82 KB

Ok, I now suspect that the automated tests don't load the UI files, which means that the rules_external_help function isn't declared. I'm wrapping it in a function in rules.module in the attached patch. If this works we need to find a better way of solving this (such as including the UI files in the automated tests).

Itangalo’s picture

Dammit.

Itangalo’s picture

Itangalo’s picture

Status: Needs review » Needs work

Ok, so the problem is that ui.forms.inc is not included when running SimpleTests. Kind of silly to have an error only triggered by tests, but it also signifies that it might be possible to load Rules stuff without the required file inclusion.

What to do?
* Move the file to another place?
* Have a commonly available wrapper function (which is the case in the patch at #23)?
* Explicitly include ui.forms.inc in the SimpleTests?
* Something else, much smarter?

I don't really know how to solve this in a good way, so any input would be great.

Itangalo’s picture

For information: I've created a module that uses a similar approach to managing external help pages, and I hope to make it a bit more sophisticated. (See http://drupal.org/project/externalhelp.) It doesn't affect Rules in any way, except that I might get some experience and ideas that may be useful here.

Itangalo’s picture

And there it is – some new ideas collected from the External Help project.

I have now added two links that are *not* explicitly used in the inline help, but listed on the help page. I have also reordered the links, making them appear in a more natural order on the help page.

Problem with inclusion of ui.forms.inc is still present.

fago’s picture

+++ b/rules_admin/rules_admin.inc
@@ -29,6 +29,13 @@ function rules_admin_reaction_overview($form, &$form_state, $base_path) {
+    '#markup' => t('Reaction rules, listed below, react on selected events on the site. Each reaction rule may fire any number of <em>actions</em>, and may have any number of <em>conditions</em> that must be met for the actions to be executed. You can also set up <a href="@url1">components</a> – stand-alone sets of rule configuration that can be used in Rules and other parts of your site. See <a href="@url2">the online documentation</a> for an introduction on how to use Rules.',

sets of Rules configuration, as it need not be a rule.

+++ b/rules_admin/rules_admin.inc
@@ -95,6 +102,11 @@ function rules_admin_components_overview($form, &$form_state, $base_path) {
+    '#markup' => t('Components are stand-alone Rules configuration that can be used by Rules and other modules on your site. Components are for example useful if you want to use the same conditions, actions or rules in multiple places, or call them from your custom module. You may also export each component separately. See <a href="@url2">the online documentation</a> for more information about how to use components.',

so let's use "sets of Rules configuration" again?

+++ b/rules_admin/rules_admin.module
@@ -90,6 +90,37 @@ function rules_admin_menu() {
+    // Sorry for returning a string of output rather than a renderable array.
+    // Apparently, this is how core wants it.

lol

+++ b/ui/ui.core.inc
@@ -1029,7 +1036,11 @@ class RulesConditionContainerUI extends RulesContainerPluginUI {
+          '#markup' => t('You are about to add a new @plugin to the @config-plugin %label. Any configuration indented under this plugin label will be a part of this plugin. See <a href="@url">the online documentation</a> for more information on condition sets.',

what does mean if a configuration is indented under a plugin?

Also, I think we should hide the "plugin" term from the user here, but use @plugin.

Then, configuration is in Rules usually the whole thing. The parts are called "elements".

I'll try to come up with an alternative. What about that?

"Use indentation to move a @plugin into the @config-plugin."

+++ b/ui/ui.data.inc
@@ -65,6 +65,8 @@ class RulesDataUI {
+      '#description' => t("The data selector helps you drill down into the data available to Rules. <em>Note that entity fields will only be available if you have used the condition 'entity has field' (or 'content is of type').</em> More useful tips about data selection is available in <a href='@url'>the online documentation</a>.",

Still, that's not true for user accounts. Should we ignore that?

+++ b/ui/ui.forms.inc
@@ -910,3 +910,70 @@ function rules_autocomplete_tags($tags_typed = '') {
+ * @param $topic
+ *   The internal key for a given topic.

What about calling this $topic_url ? The internal key for which to get a URL.

+++ b/ui/ui.forms.inc
@@ -910,3 +910,70 @@ function rules_autocomplete_tags($tags_typed = '') {
+ *   Either a url-checked URL for the given topic, or the full list of external

url-checked URL doesn't make much sense to me ;) Also, we don't need to run full url's through url() - it is already ready to use.

fago’s picture

I just ran the tests with a failing test and I had no problems - so don't mind the testbot. It fails randomly for rules :( ui.forms.inc should be fine!

@rules_help()

I'm not sure about listing all that links there. It looks a bit random to me. Do you think this gives more value than just linking to the online documentation, where the links are anyway in a structured way? Maybe we should just add a short sentence what rules is about though.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
17.04 KB

-1-
All comments in #27 now taken care of, except '$topic_url'. I see this key as the identifier of a help section, and the help section contains both a url and a label – so I still call it '$topic'.

-2-
Concerning #28 and rules_help:
To me it makes sense to have all links listed on the help page – it is a list of shortcuts to good Rules documentation, and it is also a way to find "that help link that was somewhere in the UI". However, I don't feel strongly for it, and if you think it's better with just a short help text and a general link I'm fine with that too. (That would also make the list of Rules help topics much easier, since each entry becomes a string rather than an array.)

-3-
Concerning workning/non-working tests: I have added a wrapper function for rules_external_help into rules.module, which is why the tests are working now. It is an ugly solution, and I want to find another one.
(I will make another run with the test bot, to verify that this was actually the thing that made the difference – I'm not 100% certain. But first checking *this* patch.)

Itangalo’s picture

Removing the function used for test-bot trickery. Hoping for green results.

Status: Needs review » Needs work

The last submitted patch, 1297414-30-lots_of_help_stuff.patch, failed testing.

fago’s picture

hm, looks like there is an issue :/ I'll look into it.

>All comments in #27 now taken care of, except '$topic_url'. I see this key as the identifier of a help section, and the help section contains both a url and a label – so I still call it '$topic'.

The thing is that it is very strange that the topic definition has a label and a url, but you only get the url if you pass the topic.

To me it makes sense to have all links listed on the help page – it is a list of shortcuts to good Rules documentation, and it is also a way to find "that help link that was somewhere in the UI". However, I don't feel strongly for it, and if you think it's better with just a short help text and a general link I'm fine with that too. (That would also make the list of Rules help topics much easier, since each entry becomes a string rather than an array.)

Yep, that would simplify things a bit. I don't think its necessary, but I'll leave it up to you! Or maybe someone else has an opinion.

Itangalo’s picture

Status: Needs work » Needs review
FileSize
15.59 KB

New patch!

The function for listing help pages now *only* returns URLs, and the parameter is now called '$id' rather than '$topic'. Help page updated – it now contains a few manually selected links.

The problem with including ui.forms.inc in SimpleTests is still there.

Status: Needs review » Needs work

The last submitted patch, 1297414-33-lots_of_help_stuff.patch, failed testing.

fago’s picture

Status: Needs work » Needs review
FileSize
14.9 KB

I think $topic is more descriptive than id though. I've shortly worked over the patch:
* Moved rules_help into rules
* moved rules_external_help into rules.module - now it's not long any more!

Please review.

Itangalo’s picture

Slick!

fago’s picture

Status: Needs review » Fixed

Committed - just in time for 2.0 :)

Itangalo’s picture

YEAH!
I look forward to seeing this live.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary to reflect current state.