Skip to content

Allow runnable unittests like on dlang.org #137

@wilzbach

Description

@wilzbach

Since a couple of days the dlang.org documentation allows to run unittest directly online, see e.g.

https://dlang.org/phobos-prerelease/std_algorithm_searching.html#.minElement

or for more details the PR.

This works because of this ddoc hack that allows to distinguish between unittest examples and full text examples:

DDOC_EXAMPLES  = <span class="dlang_runnable"></span>$(DDOCKEYVAL Examples, $0)

I had a quick look at ddox and it seems that it's not as straight forward to distinguish unittest examples from full-text examples, because unittest examples get converted into full-text examples i:

last_decl["comment"] ~= format("Example:\n%s\n---\n%s\n---\n", comment.strip, source);

@s-ludwig what would be the nicest way to transfer the information that an example is runnable (i.e. originates from a unittest block)?
The quick solution would be sth. similar to the ddoc "hack":

last_decl["comment"] ~= format(`<span class="dlang_runnable">\nExample:\n%s\n---\n%s\n---\n</span>`, comment.strip, source);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions