Menu

#187 Rename .txt files to .rst

None
open-fixed
None
5
2024-08-15
2022-01-05
Adam Turner
No

This change is in two parts -- the first commit does the rename and the second goes through and updates references to .txt files. All tests pass.

The benefit of this change is primarily for people -- on user interfaces with syntax highlighting (e.g. IntelliJ / VSCode / Notepad++ editors, code mirrors, etc), the text is presented natively as reStructuredText, and editor features can assist with e.g. autocompletion.

Docutils itself of course does not care which file extension is used.

I have not renamed any of the include files or template files in docutils.parsers or docutils.writers, as they form part of the public API and would need a deprecation cycle (or aliasing in the parsing code)

A

Please see https://github.com/AA-Turner/docutils/pull/3 and https://github.com/AA-Turner/docutils/pull/3.patch for the commits and patch.

Discussion

  • Günter Milde

    Günter Milde - 2022-01-05

    Docutils is quite clear about the standard filename extension for a reStructuredText file, so I don't see this accepted anytime soon.

    The policies advise:

    • Add an Emacs "local variables" block in a comment at the end of the document. See the end of this document for an example.

    Compatible editors can use this to set the editing mode.

    In the jed programmer's editor, I use a hook

    % set rst (reStructured Text) mode for some cases
    define text_mode_hook()
    {
       % Set rst_mode for text files in the Docutils SVN working dir
       % and the Docutils test dir
       if ((is_substr(buffer_filename(), "docutils") or
           is_substr(buffer_filename(), "Test/Docutils"))
           and not is_substr(buffer_filename(), "Makefile")) {
          rst_mode();
          return(1);
       }
     % ...
     }
    

    Maybe something similar is available in other "intelligent" editors, too.

     
  • Adam  Turner

    Adam Turner - 2022-01-05

    Hi Günter,

    That text was written in 2002 -- twenty years ago.

    I would argue that the de facto reality is that ".rst" is the standard extension for reStructuredText files, and has been for quite some time -- it is required for Python Enhancement Proposals (PEP 12 [1]) and the Python documentation (since 2007 [2]). Wikipedia has used the .rst extension for 10 years [3]. The linux kernel has been using .rst files for 5 years, when they switched to reStructuredText [4]. Any tool using linguist will pick up .rst as the extension (since the start of the project in 2011) [5].

    I could go on! My plea is to update the FAQ -- my suggested edit notes that "ReStructuredText files should be readable as plaintext", which I believe is in spirit of the original text. In response to the "why bother" comment in the original FAQ text -- I would argue it is as the rest of the world seems to assume that the extension is .rst, and Docutils as the official custodian of reStructuredText should embrace this.

    A


    Original FAQ text:

    What's the standard filename extension for a reStructuredText file?:
    It's ".txt". Some people would like to use ".rest" or ".rst" or
    ".restx", but why bother? ReStructuredText source files are meant to
    be readable as plaintext, and most operating systems already associate
    ".txt" with text files. Using a specialized filename extension would
    require that users alter their OS settings, which is something that
    many users will not be willing or able to do.

     
  • engelbert gruber

    Hei,

    first of all I appreciate Adam nudging, although the project must slow him down, because not every docutils user is a programmer. For example removng rst2html.py is a 2 second change for Adam (more like 2 minutes for me) but might be hard for people running the same script for 10 years.

    As for the file extension:

    1. Adam's plea (very understandable) highlighting as the editor recognizes the file extension.
    2. Editing or viewing for normal users. Will windows ask what to do with .rst files ?

    I don't know
    cheers

     
  • Adam  Turner

    Adam Turner - 2022-01-06

    Will windows ask what to do with .rst files

    Yes, if you double click on the file it will open a pop-up asking what application you want to use to edit the files, and then you can select 'notepad' (preinstalled) or any other text editor. Windows can then remember the file association.

    removng rst2html.py ... might be hard for people running the same script for 10 years

    I do understand entirely -- any change is by its very nature breaking fron the status quo ante.

    The latest patch I proposed though has no breaking changes (keeps rst2html.py etc), but less of the enhancements.

    Can I take it that you'd support this change @grubert? (Trying to forge consensus!)

    A

    P.S. I have added an image of the file association pop-up box, as it is on my Windows 10 PC.

     
  • Günter Milde

    Günter Milde - 2022-01-06
    • status: open --> pending-remind
    • assigned_to: David Goodger
     
  • Günter Milde

    Günter Milde - 2022-01-06

    The "de facto" status is why I did not reject the proposal right away.
    I am not against "endorsing" rst as extension for rST files.
    However, I remember David Goodger beeing very clear about his preference in this question on several occasions.
    I don't think it is an urgent issue, so I prefer to let David decide.

     
  • Adam  Turner

    Adam Turner - 2022-01-06

    Perhaps if we don't hear from him in a month (early Februray) we could revisit this issue? (I was taught to try to be explicit rather than 'in the future' for reminders!)

    A

     
    • engelbert gruber

      :-) yes nag in early February

      there are two sides:
      developers working on the file: it is cool if the editor knows ot is reST, therefore .rst
      readers reading some file, easing access, prefer .txt

      linux kernel documentation is developers, not users or readers.

       
      • Adam  Turner

        Adam Turner - 2022-02-16

        :-) yes nag in early February

        We're getting dangerously close to mid-late February! Sorry for my brief absence -- deadlines and real life, sadly. Hence this post with said nag ;-)

        A

         
        • engelbert gruber

          thanks for the reminder

          we still have the two opinions (developers and readers)
          and I don't have a clue :-)

           
  • Günter Milde

    Günter Milde - 2024-08-08

    Thinking about this, I now favour changing the extension of rST source files to .rst. The PEP sources at peps.python.org are an "official precedence case".

    Writer template files are not rST sources and should keep their extension.

    Standard include files shoud change after an advance warning and transition period.
    (We can implement a fallback with warning in the "include" directive implementation.)

     
    👍
    1
  • Günter Milde

    Günter Milde - 2024-08-08
    • assigned_to: David Goodger --> Adam Turner
     
  • Günter Milde

    Günter Milde - 2024-08-09

    We would need to adapt background scripts, too. I am unsure whether the following changes correctly describe the behaviour after applying this patch :

    --- a/sandbox/infrastructure/docutils-update.local
    +++ b/sandbox/infrastructure/docutils-update.local
    @@ -14,10 +14,10 @@
     #
     # ATTENTION
     #
    -# Any .html document with a corresponding .txt file is regenerated 
    -# if the .txt has changed, but no new .html files will be generated.
    +# Any .html document with a corresponding .rst file is regenerated 
    +# if the .rst has changed, but no new .html files will be generated.
     #
    -# * Funny thing: sf hides README.txt files.
    +# * Funny thing: sf hides README.rst files.
     #
     # ATTENTION
    

    I downloaded the patch set and tried to commit it to a local branch but failed:

    milde@heinz:/usr/local/src/docutils-git-svn/docutils/docutils > git am -3 /tmp/17.patch 
    Applying: Rename all .txt files to .rst
    Applying: Update references to .txt files
    Using index info to reconstruct a base tree...
    M   docutils/test/test_utils/test__init__.py
    .git/rebase-apply/patch:7937: trailing whitespace.
    # Any .html document with a corresponding .rst file is regenerated 
    error: patch failed: docutils/docs/ref/rst/history.rst:1
    error: docutils/docs/ref/rst/history.rst: patch does not apply
    error: Did you hand edit your patch?
    It does not apply to blobs recorded in its index.
    Patch failed at 0002 Update references to .txt files
    hint: Use 'git am --show-current-patch=diff' to see the failed patch
    When you have resolved this problem, run "git am --continue".
    If you prefer to skip this patch, run "git am --skip" instead.
    To restore the original branch and stop patching, run "git am --abort".
    
     
    • engelbert gruber

      sandbox/infrastructure/docutils-update.local errors will pop up when
      run , no problem to me

       

      Last edit: Adam Turner 2024-08-15
      • engelbert gruber

        infrastructure docutils-update.local should prefer .rst but falls back on
        .txt

        ./docs/user/Makefile.docutils-update

        has fixed filenames but is only one file

         

        Last edit: Adam Turner 2024-08-15
        • engelbert gruber

          i could apply the rename this week ... nag me

           

          Last edit: Adam Turner 2024-08-15
  • engelbert gruber

    nut i would only apply on svn ... might be not what's wanted

     

    Last edit: Adam Turner 2024-08-15
  • engelbert gruber

    • status: pending-remind --> open-fixed
     
  • engelbert gruber

    applied the patch

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.