Skip to content

ipython Sphinx directive executes code when excluded by only, ifconfig #9339

Closed

Description

@cgranade

The ipython directive for Sphinx provided by IPython.sphinxext.ipython_directive executes its code block at the parsing stage. As a result, even if an ipython directive is surrounded by an only or ifconfig directive with a false-y condition, the code block is still executed. I have posted a minimum working example for this issue that includes a Sphinx configuration file and a reStructuredText file to reproduce the problem.

Activity

  1. takluyver commented on Mar 21, 2016

    @takluyver
    Member

    Ping @chebee7i and @y-p who have worked on the IPython sphinx directive.

  2. chebee7i commented on Mar 27, 2016

    @chebee7i
    Contributor

    Confirmed. Not surprising however, I don't think the ipython_directive was written with those use cases in mind. Haven't yet had a chance to look into how much work would be involved to fix this.

  3. added this to the 6.0 milestone on Jun 16, 2016
  4. modified the milestones: 7.0, 6.0 on Feb 24, 2017
  5. removed this from the 7.0 milestone on Aug 28, 2018
  6. LucianaMarques commented on Oct 18, 2018

    @LucianaMarques
    Contributor

    Has any pull request been made on this? I'd like ti give it a try!

  7. added a commit that references this issue on Jun 12, 2026
    ed12889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions