Skip to content

Luals docgen #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3c3e355
proof of concept
VisenDev Sep 21, 2024
c3dd769
more types working
VisenDev Sep 21, 2024
1a04340
more types working
VisenDev Sep 21, 2024
65488f8
custom build step now working
VisenDev Sep 21, 2024
84ce7ae
integrated things better
VisenDev Sep 23, 2024
c654025
fixed segfaults, still need to add install step
VisenDev Sep 23, 2024
9133013
refactored in new file
VisenDev Sep 24, 2024
3d6b352
fixed memory corruption issues
VisenDev Sep 24, 2024
7455f58
polished implementation
VisenDev Sep 24, 2024
8b4da8b
removed old comments
VisenDev Sep 24, 2024
cd0184d
removed old testing code
VisenDev Sep 24, 2024
4704964
reworked define system to support build arguments
VisenDev Sep 25, 2024
7a3a31f
add allocator parameter
VisenDev Sep 25, 2024
6c348cb
properly close file
VisenDev Sep 25, 2024
1c27125
adding debug logging for testing
VisenDev Sep 25, 2024
a6de64c
added init capacity
VisenDev Sep 25, 2024
8d53895
added more debugging logs
VisenDev Sep 25, 2024
2a29d99
removed deinit from hashmap for testing
VisenDev Sep 25, 2024
a6d8645
allocator experiments
VisenDev Sep 25, 2024
a4d69f1
changing id test
VisenDev Sep 25, 2024
572dfac
more changes to how Ids are defined:
VisenDev Sep 25, 2024
44a7d58
reworked how arraylists are stored
VisenDev Sep 25, 2024
b4402a9
removed debugging print statements, fixed bug
VisenDev Sep 25, 2024
8f01465
minor testing change
VisenDev Sep 25, 2024
435668b
added more spacing between types
VisenDev Sep 25, 2024
b878e3f
added annotations for testing
VisenDev Sep 25, 2024
07a2388
totally reworked implementation to fix bugs
VisenDev Sep 25, 2024
547c0da
allow struct fields with default values to be null
VisenDev Sep 25, 2024
4f6f021
change how optional fields are notated
VisenDev Sep 25, 2024
6ed5166
revert back to old optional field syntax
VisenDev Sep 25, 2024
5275b0a
added unit test
VisenDev Sep 27, 2024
1c8afa7
remove outdated decls
VisenDev Sep 27, 2024
21353cb
remove error union return type from build.zig
VisenDev Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more types working
  • Loading branch information
VisenDev committed Sep 21, 2024
commit 1a04340d7de2d6ede3697ecb5e82ec0863ea1ad3
36 changes: 25 additions & 11 deletions src/luals-docgen.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");

pub const Doc = struct {
pub const Definitions = struct {
allocator: std.mem.Allocator,
defined: std.StringHashMap(std.ArrayList(u8)),

Expand All @@ -16,15 +16,15 @@ pub const Doc = struct {
self.defined.deinit();
}

pub fn addFileHeader(_: *@This(), result: *std.ArrayList(u8)) !void {
try result.appendSlice(
\\---@meta
\\
\\--- This is an autogenerated file,
\\--- Do not modify
\\
\\
);
pub fn getFileHeader(_: *@This()) []const u8 {
return
\\---@meta
\\
\\--- This is an autogenerated file,
\\--- Do not modify
\\
\\
;
}

pub fn addEnum(self: *@This(), name: []const u8, comptime T: type) !void {
Expand Down Expand Up @@ -135,6 +135,20 @@ pub const Doc = struct {
}
}

/// Warning: file contents will be lost
pub fn overwriteFile(self: *@This(), abs_path: []const u8) !void {
var file = try std.fs.openFileAbsolute(abs_path, .{ .mode = .write_only });
try file.seekTo(0);
try file.writeAll(self.getFileHeader());

var iter = self.defined.valueIterator();
while (iter.next()) |val| {
try file.writeAll(val.items);
try file.writeAll("\n");
}
try file.setEndPos(try file.getPos());
}

pub fn printDefined(self: *@This()) !void {
var iter = self.defined.valueIterator();
while (iter.next()) |val| {
Expand All @@ -144,7 +158,7 @@ pub const Doc = struct {
};

test "docgen" {
var docs = Doc.init(std.testing.allocator);
var docs = Definitions.init(std.testing.allocator);
defer docs.deinit();

const MyEnum = enum { asdf, fdsa, qwer, rewq };
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy