Skip to content

autodoc: Lookup file-as-a-struct doctests using the stem of the filename #23615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

squeek502
Copy link
Collaborator

@squeek502 squeek502 commented Apr 20, 2025

This is not a perfect solution and relies on the convention that file-as-a-struct types have the same file name as the type name. Fixes #23614

Example with FixedBufferAllocator:

image

Primarily motivated by #23613 which adds a doctest for FailingAllocator.

This is not a perfect solution and relies on the convention that file-as-a-struct types have the same file name as the type name. Fixes ziglang#23614
Comment on lines +540 to +541
// TODO: Support for doctests on file-as-a-struct types without using
// the filename to find the associated test.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@squeek502 squeek502 Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#23614 is the relevant issue until this is merged. If this is merged, I'll open a separate issue for this TODO.

To be clear, this TODO would be relevant for something like:

// Foo.zig

const Bar = @This();

test Bar {
    // ...
}

After this PR, this doctest will still fail to be found, since it only looks for Foo (based on the filename).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is that the TODO should be replaced with an issue link.

Copy link
Collaborator Author

@squeek502 squeek502 Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awkward because that issue is sort of in limbo--it only needs to exist if this PR is merged.

Happy to open an issue and replace the TODO with a link if I can get confirmation that this PR is going to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autodoc: decltests for files-as-a-struct don't show up
2 participants