1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
///! for library docs, refer to [https://github.com/jonay2000/weblab-rs](https://github.com/jonay2000/weblab-rs)
pub use weblab_assignment_structure::*;
pub use weblab_macros::*;

pub mod cli;

#[macro_export]
macro_rules! weblab_assignment_info {
    (self) => {{
        let w: $crate::WeblabAssignment = __WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO;
        w
    }};
    ($root_module: path) => {{
        use $root_module as weblab_module;
        let w: $crate::WeblabAssignment =
            weblab_module::__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO;
        w
    }};
}

#[macro_export]
macro_rules! weblab_main {
    (self, $($args: expr),*) => {
        $crate::cli::main(__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO, &[$($args.to_string()),*]);
    };
    (self) => {{
        $crate::cli::main(__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO, &std::env::args().collect::<Vec<String>>());
    }};
    ($root_module: path, $($args: expr),*) => {
        use $root_module as weblab_module;
        $crate::cli::main(weblab_module::__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO, &[$($args.to_string()),*]);
    };
    ($root_module: path) => {{
        use $root_module as weblab_module;
        $crate::cli::main(weblab_module::__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO, &std::env::args().collect::<Vec<String>>());
    }};
}

#[macro_export]
macro_rules! solution_only {
    ($($tt: tt)*) => {
        $($tt)*
    };
}

#[macro_export]
macro_rules! template_only {
    ($($tt: tt)*) => {
        $($tt)*
    };
}

#[macro_export]
macro_rules! weblab_folder {
    ($title: literal, $weight: literal, $($module: path),* $(,)?) => {
        pub mod __WEBLAB_ASSIGNMENT_METADATA {
            use $crate::*;

            pub const ASSIGNMENT_INFO: WeblabAssignment = WeblabAssignment::Folder(WeblabFolder {
                title: $title,
                weight: $weight,
                assignment_text: "",
                assignments: &[
                    $(
                        {
                            use super::*;
                            use $module as weblab_module;

                            weblab_module::__WEBLAB_ASSIGNMENT_METADATA::ASSIGNMENT_INFO
                        }
                    ),*
                ],
            });
        }
    };
    ($title: literal, $($module: path),* $(,)?) => {
        weblab_folder!($title, 1.0, $($module),*);
    };
    ($name: ident, $($module: path),* $(,)?) => {
        weblab_folder!(stringify!($name), $($module),*);
    };
    ($name: ident, $weight: literal, $($module: path),* $(,)?) => {
        weblab_folder!(stringify!($name), $weight, $($module),*);
    };
}