← GDG /

#298 gdtest_mock_code

#298 gdtest_mock_code OK INIT
Mock code cells and output-title containers
Mock code cells (source-code: mock) and output-title containers. Tests that the preprocessor splits mock cells into display + eval pairs, output-title wraps output in titled containers on both mock and regular cells, mock cells with no delimiter are display-only, and multiple mock cells work on a single page.
View Site → Build Log ๐Ÿงช Test Coverage

Build Mode

○ No great-docs.yml

This package has no pre-supplied config. It tests the full great-docs initgreat-docs build pipeline from scratch, relying entirely on auto-detection of the package layout, docstring style, and exports.

Dimensions

A1 B1 C1 D1 E6 F6 G1 H7
A1Flat layoutlayout
B1Explicit __all__exports
C1Functions onlyobjects
D1NumPydocstrings
E6No directivesdirectives
F6No user guideuser_guide
G1README.mdlanding
H7No extrasextras

Source Files

๐Ÿ“ gdtest_mock_code/
๐Ÿ“„ __init__.py
"""Test package for mock code cells and output-title."""

__version__ = "0.1.0"
__all__ = ["add", "multiply", "greet"]


def add(a: int, b: int) -> int:
    """
    Add two numbers.

    Parameters
    ----------
    a
        First number.
    b
        Second number.

    Returns
    -------
    int
        Sum of a and b.

    Examples
    --------
    ```python
    from gdtest_mock_code import add

    add(2, 3)
    ```
    """
    return a + b


def multiply(a: int, b: int) -> int:
    """
    Multiply two numbers.

    Parameters
    ----------
    a
        First number.
    b
        Second number.

    Returns
    -------
    int
        Product of a and b.
    """
    return a * b


def greet(name: str) -> str:
    """
    Greet someone by name.

    Parameters
    ----------
    name
        The person to greet.

    Returns
    -------
    str
        A greeting string.
    """
    return f"Hello, {name}!"
๐Ÿ“ user_guide/
๐Ÿ“„ 01-basic-mock.qmd
---
title: Basic Mock Cell
---

A basic mock cell splits display code from eval code.

```{python}
#| source-code: mock
import gdtest_mock_code

gdtest_mock_code.add(10, 20)
# ---
from gdtest_mock_code import add
add(10, 20)
```

The reader sees `gdtest_mock_code.add(10, 20)` but the cell
actually runs `from gdtest_mock_code import add; add(10, 20)`.
๐Ÿ“„ 02-mock-output-title.qmd
---
title: Mock with Output Title
---

Combines `source-code: mock` with `output-title`.

```{python}
#| source-code: mock
#| output-title: Addition Result
gdtest_mock_code.add(3, 4)
# ---
from gdtest_mock_code import add
add(3, 4)
```

The output should appear inside a titled container
labelled "Addition Result".
๐Ÿ“„ 03-standalone-output-title.qmd
---
title: Standalone Output Title
---

`output-title` works on regular (non-mock) executable cells too.

```{python}
#| output-title: Greeting Output
from gdtest_mock_code import greet
greet("World")
```

The output should appear inside a titled container
labelled "Greeting Output".
๐Ÿ“„ 04-no-delimiter.qmd
---
title: No Delimiter Mock
---

A mock cell with no `# ---` delimiter is display-only
(equivalent to `eval: false`).

```{python}
#| source-code: mock
gdtest_mock_code.multiply(6, 7)
```

There is no eval cell emitted, so no output appears.
๐Ÿ“„ 05-multiple-mocks.qmd
---
title: Multiple Mock Cells
---

A page with several mock cells interleaved with prose.

## First calculation

```{python}
#| source-code: mock
gdtest_mock_code.add(1, 2)
# ---
from gdtest_mock_code import add
add(1, 2)
```

## Second calculation

```{python}
#| source-code: mock
#| output-title: Product
gdtest_mock_code.multiply(3, 4)
# ---
from gdtest_mock_code import multiply
multiply(3, 4)
```

## Third โ€” a greeting

```{python}
#| source-code: mock
#| output-title: Greeting
gdtest_mock_code.greet("GDG")
# ---
from gdtest_mock_code import greet
greet("GDG")
```
๐Ÿ“„ 06-html-repr-output-title.qmd
---
title: HTML Repr with Output Title
---

When `output-title` wraps a rich HTML object like a GT table
the container should go frameless โ€” no double border.

### GT table with output-title

```{python}
#| source-code: mock
#| output-title: Example Table
import great_tables as gt
import pandas as pd

gt.GT(pd.DataFrame({"x": [1, 2], "y": [3, 4]}))
# ---
from great_tables import GT
import pandas as pd

GT(pd.DataFrame({"x": [1, 2], "y": [3, 4]}))
```

### GT table without output-title (baseline)

```{python}
#| source-code: mock
import great_tables as gt
import pandas as pd

gt.GT(pd.DataFrame({"a": [10, 20], "b": [30, 40]}))
# ---
from great_tables import GT
import pandas as pd

GT(pd.DataFrame({"a": [10, 20], "b": [30, 40]}))
```

### Plain text with output-title (framed)

```{python}
#| output-title: Text Output
from gdtest_mock_code import greet
greet("comparison")
```

The GT table with output-title should show a floating label
with no frame.  The baseline GT table (no output-title) should
render identically to any other GT table.  The text output
should keep its frame.
๐Ÿ“„ 07-output-frame.qmd
---
title: Output Frame (No Title)
---

The `output-frame` option adds a bordered container around
cell output without a title label.

### Framed output (no title)

```{python}
#| output-frame: true
from gdtest_mock_code import greet
greet("framed")
```

### Framed output with mock cell

```{python}
#| source-code: mock
#| output-frame: true
gdtest_mock_code.add(5, 5)
# ---
from gdtest_mock_code import add
add(5, 5)
```

### Unframed output (baseline)

```{python}
from gdtest_mock_code import greet
greet("no frame")
```

The first two outputs should have a border but no title
header.  The third should render as a normal cell output.
๐Ÿ“„ README.md
# gdtest-mock-code

Synthetic test for `source-code: mock` and `output-title`.

## Purpose

Tests that Great Docs correctly:

- Splits mock cells into display + eval pairs
- Wraps output in titled containers when `output-title` is set
- Frames output without a title when `output-frame: true` is set
- Handles `output-title` on non-mock cells
- Handles mock cells with no delimiter (display-only)
- Handles multiple mock cells on one page
- Goes frameless for rich HTML outputs (GT tables)
๐Ÿ“„ great-docs.yml generated
# Great Docs Configuration
# See https://posit-dev.github.io/great-docs/user-guide/configuration.html

# Module Name (optional)
# ----------------------
# Set this if your importable module name differs from the project name.
# Example: project 'py-yaml12' with module name 'yaml12'
# module: yaml12

# Docstring Parser
# ----------------
# The docstring format used in your package (numpy, google, or sphinx)
parser: numpy

# Dynamic Introspection
# ---------------------
# Use runtime introspection for more accurate documentation (default: true)
# Set to false if your package has cyclic alias issues (e.g., PyO3/Rust bindings)
dynamic: true

# API Discovery Settings
# ----------------------
# Exclude items from auto-documentation
# exclude:
#   - InternalClass
#   - helper_function

# Logo & Favicon
# ---------------
# Point to a single logo file (replaces the text title in the navbar):
# logo: assets/logo.svg
#
# For light/dark variants:
# logo:
#   light: assets/logo-light.svg
#   dark: assets/logo-dark.svg
#
# To show the text title alongside the logo, add: show_title: true

# Funding / Copyright Holder
# --------------------------
# Credit the organization that funds or holds copyright for this package.
# Displays in sidebar and footer. Homepage and ROR provide links.
# funding:
#   name: "Posit Software, PBC"
#   roles:
#     - Copyright holder
#     - funder
#   homepage: https://posit.co
#   ror: https://ror.org/03wc8by49

# API Reference Structure
# -----------------------
# Customize the sections below to organize your API documentation.
# - Reorder items within a section to change their display order
# - Move items between sections or create new sections
# - Use 'members: false' to exclude methods from documentation
# - Add 'desc:' to sections for descriptions

reference:
  - title: Functions
    desc: Utility functions
    contents:
      - add
      - greet
      - multiply

# Site URL
# --------
# Canonical address of the deployed documentation site.
# Required for subdirectory deployments, skills page install commands,
# .well-known/ discovery, and sitemaps.
# site_url: "https://your-org.github.io/your-package/"

# Site Settings
# -------------
# site:
#   theme: flatly              # Quarto theme (default: flatly)
#   toc: true                  # Show table of contents (default: true)
#   toc-depth: 2               # TOC heading depth (default: 2)
#   toc-title: On this page    # TOC title (default: "On this page")

# Jupyter Kernel
# --------------
# Jupyter kernel to use for executing code cells in .qmd files.
# This is set at the project level so it applies to all pages, including
# auto-generated API reference pages. Can be overridden in individual .qmd
# file frontmatter if needed for special cases.
jupyter: python3

# CLI Documentation
# -----------------
# cli:
#   enabled: true              # Enable CLI documentation
#   module: my_package.cli     # Module containing Click commands
#   name: cli                  # Name of the Click command object