Skip to content

flake8 and Sphinx directives #3802

Closed

Description

@rob-miller

I would like to be able to use Sphinx directives like :class: and :meth: in my code documentation, but it is blocked by Flake8:

Bio/PDB/internal_coords.py:3595:1: RST304 Unknown interpreted text role "meth".

Is there anyway I can get around this? Would it be reasonable to have Flake8 ignore RST304?
I see @peterjc has looked around this, but not sure where it is now.
It seems like a very nice feature (and I just spent two days polishing my documentation, only to find I can't commit :-( )

Activity

  1. peterjc commented on Nov 23, 2021

    @peterjc
    Member

    Rather than ignoring RST304, specify which roles you are using via the .flake8 configuration - see https://github.com/peterjc/flake8-rst-docstrings

    [flake8]
    rst-roles =
        class,
        func,
        ref,
    rst-directives =
        envvar,
        exception,
    extend-ignore =
        RST307,
        # ...
    
  2. rob-miller commented on Nov 24, 2021

    @rob-miller
    ContributorAuthor

    Thank you, that worked. Could/should this be added to the distribution .flake8?
    In my particular case the added lines are:

    rst-roles =
        class,
        func,
        meth,
        mod,
        data,
    rst-directives =
        seealso,
        todo,
    

    but now I hit the same issues in the continuous integration style check.

    Also did you change to enforcing the 79 character line length?

  3. rob-miller commented on Nov 25, 2021

    @rob-miller
    ContributorAuthor

    OK, I see where I messed up and very sorry to anyone (@mdehoon) if you pulled my version that rm'd your .flake8.

    .flake8 restored to distribution in last pushed commit.

    So how do I resolve? For now I have 'stashed' the Sphinx directives in my PR by changing them to something that gets past the distribution's .flake8.

    Happy to do a tiny PR for .flake8 rather than sneak it in if/when #3774 is merged, but probably a longer list of roles and directives is desirable beyond the ones I'm using so far?

  4. peterjc commented on Nov 26, 2021

    @peterjc
    Member

    Your proposed additions to flake8 for Sphinx look fine, I'd be happy to take that as a small self contained PR - and once merged that should make #3774 easier to finish.

    Regarding line length, is this about docstrings specifically? Currently we ignore E501 so don't bother to set the flake8 line length limit (which as I recall is 79 by default, and would need to be increased to a least the black default of 88).

  5. peterjc commented on Nov 26, 2021

    @peterjc
    Member

    If you'd rather add the roles and directives to .flake8 as part of your main PR, that's fine too - but I lean towards doing the flake8 changes first.

  6. rob-miller commented on Nov 26, 2021

    @rob-miller
    ContributorAuthor
  7. peterjc commented on Nov 30, 2021

    @peterjc
    Member

    Applied, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions