[Police] Add README.md to each submodule or not

Created on 26 February 2023, about 2 years ago

Problem/Motivation

Currently, README.md files are not available for each sub-modules. Instead, the documentation is contained within the .module files to facilitate parsing by api.drupal.org.

As a coder who reads source code, I prefer to read the README first. Visiting api.drupal.org is an option, but usually, I was leading to there by search engines. If I have the source code on my local, I read the README.md first.

And I read a message on slack recently that api.drupal.org was not working well.

Steps to reproduce

Proposed resolution

Extract a README.md file from the .module file for each submodule -- Chatgpt may help. Remove those long comment blocks from .module files.

Fewer lines would be better in code or TLDR.

Remaining tasks

User interface changes

API changes

Data model changes

๐ŸŒฑ Plan
Status

Active

Version

4.0

Component

Other

Created by

๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jungle
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    I agree with your proposed resolution @jungle, moving the documentation out from each and into a README.md makes a lot of sense.

    So, as an example, would it mean deleting this part from the js_example.module?

    /**
     * @defgroup js_example Example: JavaScript
     * @ingroup examples
     * @{
     * Examples using Drupal 8's built-in JavaScript.
     *
     * We have two examples here.
     *
     * One 'weights' content and then sorts it by weight. This demonstrates
     * attaching JavaScript through Drupal's render arrays.
     *
     * The other demonstrates adding an accordion effect to content, through
     * Drupal's theme layer.
     */
    

    New README.md file (D8 reference removed):

    # Examples using Drupal's built-in JavaScript.
    
    We have two examples here.
    
    One 'weights' content and then sorts it by weight. This demonstrates
    attaching JavaScript through Drupal's render arrays.
    
    The other demonstrates adding an accordion effect to content, through
    Drupal's theme layer.
    
  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Added child issue creation as a task under "Proposed resolution".

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    I copied and pasted the content of file_example.module file into chatgpt, and asked it to do it for me, it works well to me.

    See the commit here

    The sample instruction i used, FYI

    Extract a REAME.md file from the content following, wrap it in less than 80 chars for each line of the answer and give me the answer in a markdown code block.

    THE CONTENT OF THE MODULE FILE

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    So, as an example, would it mean deleting this part from the js_example.module:

    Go ahead please with the suggestion in #5 if you like, thanks!

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Meanwhile, we are using GitLab more and more, it parses README.md automatically. Let's do it.

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Re #3 yes, for the example of removal, see this commit

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Meanwhile, I am considering using ChatGPT to help and translate the READ.md file into other languages. It can lower the barrier more or less for learning from the examples module.

    The file structure would be

    README.md // English by default
    README
       - zh-hans/README.md // Chinese,
       - es/README.md // Spanish
       - fr/README.md // French
       ... 
    

    All README.md files will be parsed/rendered automatically on GitLab as well. And each transition should be reviewed by a native before gets committed.

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Or replace the folder name README with README_translations in the suggested file structure.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Great idea with the different languages @jungle!

    I found this page: https://gitlab.com/postgres-ai/database-lab/-/blob/master/translations/R...

    So maybe a structure like this would work, same as theirs?

    README.md // English by default
    translations
      - README.chinese-zh-hans.md
      - README.spanish.md
      - README.french.md
       ... 
    

    Maybe we should start out with creating the sub-theme README.md's from the .module content, since that text has been curated and written by one or more persons, but use ChatGPT for translating, like you suggest? At some point, the texts can be rewritten with the help of ChatGPT, if we decide so.

    Also, are you able to create a "Documentation" option under "Component" for issues?

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    I have created ๐Ÿ“Œ Create README.md for Example: JavaScript sub-module (js_example) Needs review ready for review. Should we add translation issues for "JavaScript examples" as child issues under that issue to keep it ordered?

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Also, are you able to create a "Documentation" option under "Component" for issues?

    Added

    README.md // English by default
    translations
    - README.chinese-zh-hans.md
    - README.spanish.md
    - README.french.md
    ...

    The structure works, but I still think the following is better.

    README.md // English by default
    README-translations // A directory indicates that there are README translations inside and ONLY!
        zh-hans // Using language code is fine, I think.
            README.md // Chinese translation, Entering this zh-hans, this is the only file, and Gitlab recognizes it automatically
        es // Spanish
            README.md // Spanish translation
        ...
    
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    @ressa, I did send this issue to #examples-module and #documentaion in Drupal slack, hopefully, We can get agreement or feedback from them, and I would suggest holding on for a day or two, at least, before taking any further contributions. As I am not the only maintainer of this project, others may have different opinions. This is a kind of broken change. -- content of this module on api.drupal.org gets affected.

    Many thanks!

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Thanks for the new "Documentation" Component :)

    I prefer to keep paths and names short, and have all files in the same folder for less clicking, which is why I suggest this structure:

    examples/translations/README.german.md

    This is also fine:

    examples/README-translations/README.german.md

    What would be the benefits of having the translations in individual folders?

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Good idea, let's get some more opinions :)

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
    - README.md
    - README-translations/zh-hans/README.md
    - README-translations/es/README.md
    - README-translations/fr/README.md
    - ...
    

    Suggested file pathes are the above. Or another variation: replace README-translations with README.translations

    - README.md
    - README.translations/zh-hans/README.md
    - README.translations/es/README.md
    - README.translations/fr/README.md
    - ...
    
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    The root is each submodule in my suggestion.

    - js_example/README.md
    - js_example/README.translations/zh-hans/README.md
    - js_example/README.translations/es/README.md
    - js_example/README.translations/fr/README.md
    - ...

    > What would be the benefits of having the translations in individual folders?

    Let's see what others say :)

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Ah yes, the README.md would get rendered, true. In that case the number of clicks required to read the content would be the same with these two paths:

    - js_example/README.translations/fr/README.md
    - js_example/translations/README.french.md
    
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    > valthebald: for README.md, will this be compatible with core's help_topics module?
    > valthebald: it would be great to do so
    > valthebald @jungle ^
    > jungle: Hi, @valthebald no plan from me for that, to me, personally, itโ€™s optional, README.md is enough for me as a dev. itโ€™s an Experimental module in Drupal 9, I do not think itโ€™s widely adopted by contrib modules, โ€” just guess.
    >jungle: even implementing hook_help is optional to me.

    Chatting messages from slack.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark ressa Copenhagen

    Great to see there's discussion going on, thanks for sharing!

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    There are more discussions continued with the above on slack, for the full messages in the thread, please view it here,

    The summary we agreed on:

    • Continue with extracting a README.md from the .module file to avoid credits gaming, do it in one go, or do it with 3-5 submodules per batch.
    • To have an example of help_topics: help_topics_example, โœจ Add help_topics example Active , postpone the implementation or integration of help_topics into examples.
    • Allow to accept translations of README.md, but optional, for the syncing. If the translation is outdated, give it a time window, e.g. one or two weeks to update or it gets removed.

    Thanks @valthebald and @andypost

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China

    Updating Proposed resolution

  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • ๐Ÿ‡จ๐Ÿ‡ณChina jungle Chongqing, China
  • Status changed to Closed: won't fix about 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Since the plan described here is to remove the documentation comments and replace them with an external file, I would say this is a won't fix. Documentation in code is preferable because it requires editing a single file, instead of two or more files, which makes the process easier and less prone to mistakes.

    I am not sure moving the information in Markdown files has any pro using api.drupal.org does not have. api.drupal.org is able to provide a list of classes, methods, functions, and constant that Markdown files are not able to provide.

Production build 0.71.5 2024