Change emit-docs?

Good morning,
I read that you can no longer do emit-docs = .emit

we are talking about Step.Compile.getEmittedDocs but what does that mean please

//Build step to generate docs:  

    const docs = b.addTest(.{
    .name = "Gencurs",
    .root_source_file = .{ .path = "./Gencurs.zig" },
    .target = target,
    .optimize = optimize,

    });



    docs.addIncludePath(.{.path = "./lib/"});
    docs.linkLibC();
    docs.addObjectFile(.{.cwd_relative = "/usr/lib/libpcre2-posix.so"});
    docs.addModule("dds"   , dds);
    docs.addModule("cursed", cursed);
    docs.addModule("utils" , utils);
    docs.addModule("forms" , forms);
    docs.addModule("grid"  , grid);
    docs.addModule("match" , match);
    docs.addModule("mdlPanel" , mdlPanel);
    docs.addModule("mdlObjet" , mdlObjet);
    
    beug ????? 
    docs.emit_docs = .emit;


    
    
    const docs_step = b.step("docs", "Generate docs");
    docs_step.dependOn(&docs.step);

could we have an example to generate documentation.

doc.emit_docs=.emit is no longer functional

and what is it replaced by? please

1 Like

zig build-obj -femit-docs myprogram.zig -->OK single program not import

zig build-obj -femit-docs --build-file buildmyprograme.zig → very bad buidlfile

zig build docs --build-file buildmyprograme.zig → beug and

docs.emit_docs = .emit;

zig build-obj -femit-docs myprogram.zig → bad because of import dependencies

Hello
I found while digging through the bug requests

    //Build step to generate docs:  
  
    const docs = b.addTest(.{
    .name = "Gencurs",
    .root_source_file = .{ .path = "./Gencurs.zig" },
    //.target = target,
    //.optimize = optimize,
    });



    docs.addIncludePath(.{.path = "./lib/"});
    docs.linkLibC();
    docs.addObjectFile(.{.cwd_relative = "/usr/lib/libpcre2-posix.so"});
    docs.addModule("dds"   , dds);
    docs.addModule("cursed", cursed);
    docs.addModule("utils" , utils);
    docs.addModule("forms" , forms);
    docs.addModule("grid"  , grid);
    docs.addModule("match" , match);
    docs.addModule("mdlPanel" , mdlPanel);
    docs.addModule("mdlObjet" , mdlObjet);
    
    const install_docs = b.addInstallDirectory(.{
        .source_dir = docs.getEmittedDocs(),
        .install_dir = .prefix,
        .install_subdir = "Doc_Gencurs",   // exemple
    });

    
    const docs_step = b.step("docs", "Generate docs");
    docs_step.dependOn(&install_docs.step);
    docs_step.dependOn(&docs.step);
2 Likes

(JPL’s answer is correct, but I just thought I’d add a bit of detail here)

As the release notes mention, getEmittedDocs is the new method of accessing generated documentation. If that function is used to get a LazyPath, the build system will automatically trigger documentation generation to the returned directory.

Let’s say you have a std.Build.Step.Compile named lib, and you want to generate documentation for it and put it in the doc/ directory in the install prefix (zig-out/ by default). We’ll do this using an InstallDir step, which copies a directory of files to the installation prefix. Assuming your *std.Build is named b, your code would look like this:

b.installDirectory(.{
    .source_dir = lib.getEmittedDocs(),
    .install_dir = .prefix,
    .install_subdir = "doc",
});

The idea here is that we’re separating documentation generation from installation: the former is handled by getEmittedDocs and the latter by the InstallDir step. source_dir is telling the step what it is we want to copy (in this case the documentation directory); install_dir is the root path we’re going into (.prefix means the installation prefix); and install_subdir is the string subdir we want to go to (in this case "doc"). So this will generate the documentation for lib and copy it into to zig-out/doc/ by default.

Hope this explanation made sense :slight_smile:

4 Likes