import os

from invoke.tasks import task
from invoke.runner import run


docs_dir = 'docs'
build = os.path.join(docs_dir, '_build')


@task
def clean_docs():
    run("rm -rf %s" % build)


@task
def browse_docs():
    run("open %s" % os.path.join(build, 'index.html'))


@task
def docs(clean=False, browse=False):
    if clean:
        clean_docs.body()
    run("sphinx-build %s %s" % (docs_dir, build), pty=True)
    if browse:
        browse_docs.body()

import os

from invoke.tasks import task
from invoke.runner import run


docs_dir = 'docs'
build = os.path.join(docs_dir, '_build')


@task
def clean_docs():
    run("rm -rf %s" % build)


@task
def browse_docs():
    run("open %s" % os.path.join(build, 'index.html'))


@task
def docs(clean=False, browse=False):
    if clean:
        clean_docs()
    run("sphinx-build %s %s" % (docs_dir, build), pty=True)
    if browse:
        browse_docs()

Leverage __call__ on task downstream
Leverage __call__ on task downstream

  import os
  
  from invoke.tasks import task
  from invoke.runner import run
  
  
  docs_dir = 'docs'
  build = os.path.join(docs_dir, '_build')
  
  
  @task
  def clean_docs():
      run("rm -rf %s" % build)
  
  
  @task
  def browse_docs():
      run("open %s" % os.path.join(build, 'index.html'))
  
  
  @task
  def docs(clean=False, browse=False):
      if clean:
-         clean_docs.body()
+         clean_docs()
      run("sphinx-build %s %s" % (docs_dir, build), pty=True)
      if browse:
-         browse_docs.body()
+         browse_docs()
  
Leverage __call__ on task downstream
## Code Before:
import os

from invoke.tasks import task
from invoke.runner import run


docs_dir = 'docs'
build = os.path.join(docs_dir, '_build')


@task
def clean_docs():
    run("rm -rf %s" % build)


@task
def browse_docs():
    run("open %s" % os.path.join(build, 'index.html'))


@task
def docs(clean=False, browse=False):
    if clean:
        clean_docs.body()
    run("sphinx-build %s %s" % (docs_dir, build), pty=True)
    if browse:
        browse_docs.body()

## Instruction:
Leverage __call__ on task downstream
## Code After:
import os

from invoke.tasks import task
from invoke.runner import run


docs_dir = 'docs'
build = os.path.join(docs_dir, '_build')


@task
def clean_docs():
    run("rm -rf %s" % build)


@task
def browse_docs():
    run("open %s" % os.path.join(build, 'index.html'))


@task
def docs(clean=False, browse=False):
    if clean:
        clean_docs()
    run("sphinx-build %s %s" % (docs_dir, build), pty=True)
    if browse:
        browse_docs()
