Skip to content

Section heading is duplicated if Python submodule rather than class/function is included #401

@cliffckerr

Description

@cliffckerr

I have a project that looks like this:

  ⎿  example
     ├── index.qmd
     ├── my_module
     │   ├── submodule.py
     ├── _quarto.yml

Each of my submodules has a lot of classes, so I don't want to specify them manually -- I want quartodoc to automatically list them. It does this very well, except the title of the module is duplicated below the heading in inline code format (the second submodule):

Image

I think this is happening because it's trying to render the module as it would a class or function, i.e. with the call signature. But for submodules, which have no signature, it looks a little odd. Would it be possible to remove this text?

Reproducible example

_quarto.yml

project:
  type: website
  title: "My Module Documentation"

website:
  title: "My Module Documentation"
  navbar:
    left:
      - href: index.qmd
        text: Home
      - href: reference/
        text: Reference

quartodoc:
  style: pkgdown
  dir: reference
  package: my_module
  sections:
    - title: "Module"
      desc: "Main module"
      contents:
        - submodule

(Note: the issue doesn't happen if contents explicitly includes the individual classes rather than the whole submodule.)

index.qmd

---
title: "My Module Documentation"
---

Illustrate submodule rendering issue

my_module/submodule.py

"""A sample submodule for quartodoc"""

class Calculator:
    """A class for performing mathematical calculations."""
    def __init__(self, a, b):
        self.a = a
        self.b = b
    
    def add(self):
        """Add two numbers together."""
        return self.a + self.b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions