# Buggy code
def add_totals(
    self,
    show: Optional[bool] = True,
    sort: Literal["ascending", "descending"] = None,
    size: Optional[float] = 0.8,
    color: Optional[Union[ColorLike, Sequence[ColorLike]]] = None,
):
    """
    Show barplot for the number of cells in in `groupby` category.

    The barplot is by default shown on the right side of the plot or on top
    if the axes are swapped.

    Parameters
    ----------
    show : bool, default True
    sort : Set to either 'ascending' or 'descending' to reorder the categories
        by cell number
    size : size of the barplot. Corresponds to width when shown on
        the right of the plot, or height when shown on top.
    color: Color for the bar plots or list of colors for each of the bar plots.
        By default, each bar plot uses the colors assigned in `adata.uns[{groupby}_colors.
    Returns
    -------
    BasePlot

    Examples
    --------
    >>> adata = sc.datasets.pbmc68k_reduced()
    >>> markers = {{'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}}
    >>> sc.pl.BasePlot(adata, markers, groupby='bulk_labels').add_totals().show()
    """
    self.group_extra_size = size

    if not show:
        # hide totals
        self.plot_group_extra = None
        self.group_extra_size = 0
        return self

    _sort = True if sort is not None else False
    _ascending = True if sort == "ascending" else False
    counts_df = self.obs_tidy.index.value_counts(sort=_sort, ascending=_ascending)

    if _sort:
        self.categories_order = counts_df.index

    self.plot_group_extra = {
        "kind": "group_totals",
        "width": size,
        "sort": sort,
        "counts_df": counts_df,
        "color": color,
    }
    return self


# Traceback (sphinx.errors.SphinxWarning)
/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/setuptools_scm/git.py:68: UserWarning: "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/checkouts/1204" is shallow and may cause errors
warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/checkouts/1204/docs/conf.py:112: RemovedInSphinx40Warning: The app.add_stylesheet() is deprecated. Please use app.add_css_file() instead.
app.add_stylesheet('css/custom.css')

Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/cmd/build.py", line 280, in build_main
app.build(args.force_all, filenames)
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/application.py", line 348, in build
self.builder.build_update()
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 299, in build_update
len(to_build))
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 311, in build
updated_docnames = set(self.read())
File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/contextlib.py", line 88, in __exit__
next(self.gen)
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/util/logging.py", line 213, in pending_warnings
memhandler.flushTo(logger)
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/util/logging.py", line 178, in flushTo
logger.handle(record)
File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/logging/__init__.py", line 1454, in handle
self.callHandlers(record)
File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/logging/__init__.py", line 1516, in callHandlers
hdlr.handle(record)
File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/logging/__init__.py", line 861, in handle
rv = self.filter(record)
File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/logging/__init__.py", line 720, in filter
result = f.filter(record)
File "/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/envs/1204/lib/python3.6/site-packages/sphinx/util/logging.py", line 415, in filter
raise SphinxWarning(location + ":" + str(message))
sphinx.errors.SphinxWarning: /home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/checkouts/1204/scanpy/plotting/_dotplot.py:docstring of scanpy.pl.dotplot:122:Inline strong start-string without end-string.

Warning, treated as error:
/home/docs/checkouts/readthedocs.org/user_builds/icb-scanpy/checkouts/1204/scanpy/plotting/_dotplot.py:docstring of scanpy.pl.dotplot:122:Inline strong start-string without end-string.

# Fixed code
def add_totals(
    self,
    show: Optional[bool] = True,
    sort: Literal["ascending", "descending"] = None,
    size: Optional[float] = 0.8,
    color: Optional[Union[ColorLike, Sequence[ColorLike]]] = None,
):
    """\
        Show barplot for the number of cells in in `groupby` category.

        The barplot is by default shown on the right side of the plot or on top
        if the axes are swapped.


        Parameters
        ----------
        show
            Boolean to turn on (True) or off (False) 'add_dendrogram'
        sort
            Set to either 'ascending' or 'descending' to reorder the categories
            by cell number
        size
            size of the barplot. Corresponds to width when shown on
            the right of the plot, or height when shown on top.
        color
            Color for the bar plots or list of colors for each of the bar plots.
            By default, each bar plot uses the colors assigned in
            `adata.uns[{groupby}_colors]`.


        Returns
        -------
        BasePlot


        Examples
        --------
        >>> adata = sc.datasets.pbmc68k_reduced()
        >>> markers = {{'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}}
        >>> sc.pl.BasePlot(adata, markers, groupby='bulk_labels').add_totals().show()
        """
    self.group_extra_size = size

    if not show:
        # hide totals
        self.plot_group_extra = None
        self.group_extra_size = 0
        return self

    _sort = True if sort is not None else False
    _ascending = True if sort == "ascending" else False
    counts_df = self.obs_tidy.index.value_counts(sort=_sort, ascending=_ascending)

    if _sort:
        self.categories_order = counts_df.index

    self.plot_group_extra = {
        "kind": "group_totals",
        "width": size,
        "sort": sort,
        "counts_df": counts_df,
        "color": color,
    }
    return self