# Zig Autodoc : exclude anonymous imports?

**URL:** <https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276>\
**Category:** Help\
**Tags:** build-system, autodoc\
**Created:** [February 16, 2024, 1:36pm UTC](https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276 "2024-02-16T13:36:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [February 16, 2024, 1:36pm UTC](https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276/1 "2024-02-16T13:36:07Z")

</div>

I was playing around with autodoc lately, and encountered an issue with anonymous imports, getting

```zig
error: error: ModuleNotFound

```

when calling a step that creates docs via `getEmittedDocs()`. The anonymous import is added to the module in the build.zig and works fine, also the autodoc generation works fine, just not the combination of the two 🙂

- is there a way to exclude imports from autodoc?
- I know this feature is quiet new but is there some documentation on the autodoc feature in general?

---

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [February 16, 2024, 6:59pm UTC](https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276/2 "2024-02-16T18:59:00Z")

</div>

Try to define a simple zig source for emitting docs. I am doing this mostly because I don’t want to wait for documentation generation when testing.

```zig
    // docs:
    const doc_tests = b.addTest(.{
        .root_source_file = .{ .path = "src/root.zig" },
        .target = target,
        .optimize = optimize,
    });
    const install_docs = b.addInstallDirectory(.{
        .source_dir = doc_tests.getEmittedDocs(),
        .install_dir = .prefix,
        .install_subdir = "docs",
    });
    const docs_step = b.step("docs", "Generate documentation");
    docs_step.dependOn(&install_docs.step);

```

`install_docs` creates the directory zig-out/docs  
for `doc_tests` don’t use your full module set, but a simpler zig source that includes the wanted documentation.

---

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [February 16, 2024, 7:10pm UTC](https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276/3 "2024-02-16T19:10:30Z")

</div>

Right, this might be the better choice in my case, to only generate docs for specific parts of the module.

In general though, it might be good to have both options; to exclude specific parts (.zig files, imports etc.) as well.

---

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [May 30, 2024, 1:42pm UTC](https://ziggit.dev/t/zig-autodoc-exclude-anonymous-imports/3276/4 "2024-05-30T13:42:50Z")

</div>

It’s been a while since I looked at the autodocs feature, it seems that a significant revision was done since last time. Anonymous modules do not seem to be a problem anymore.

What (kind of) worked in the past, that you could just open the index.html in your browser, now doesn’t work anymore. But you can run the docs on a local server, e.g. via

`python -m http.server -b 127.0.0.1 [some-unused-port] -d [your-docs-dir]/`.
