zig icon indicating copy to clipboard operation
zig copied to clipboard

autodoc: better indentation handling when rendering source code

Open HydroH opened this issue 1 year ago • 1 comments

Closes #19293

HydroH avatar Mar 24 '24 16:03 HydroH

Can you share a screenshot to demonstrate your work?

andrewrk avatar Mar 24 '24 23:03 andrewrk

Can you share a screenshot to demonstrate your work?

Sure. This is a comparison between this pr and master branch rendered docs. I chose a function with nested blocks and comments, which should be a good demonstration. image image

HydroH avatar Mar 25 '24 05:03 HydroH

Looks good to me!

I know what (AFAICT) this code ought to do, but could you give a screenshot of an example where some of the code has lower indentation than the start of the block? e.g.

const S = struct {
    const foo = {};
    test foo {
        const x: [2]u8 =
        // zig fmt: off
.{ 10, 20 };
        // zig fmt: on
        _ = x;
    }
};

Assuming I'm reading this right, the test should render like this (which I would consider ideal):

test foo {
    const x: [2]u8 =
    // zig fmt: off
.{ 10, 20 };
    // zig fmt: on
    _ = x;
}

This is the result for the following code:

        pub fn testIndent() void {
            const x: [2]u8 =
                // zig fmt: off
.{ 10, 20 };
            // zig fmt: on
            _ = x;
        }

image

HydroH avatar Mar 25 '24 06:03 HydroH

Brilliant, I'm happy with this then - thanks!

mlugg avatar Mar 25 '24 06:03 mlugg