autodoc: better indentation handling when rendering source code
Closes #19293
Can you share a screenshot to demonstrate your work?
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.
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;
}
Brilliant, I'm happy with this then - thanks!