@@ -9,174 +9,175 @@ namespace fs = std::filesystem;
9
9
using std::optional;
10
10
using std::string;
11
11
12
- string package_doc (Package p);
13
- string package_idx (PackageList p);
12
+ string package_doc ( Package p );
13
+ string package_idx ( PackageList p );
14
14
15
15
/* ******************************************************************
16
16
* Generates documentation webpages for each package
17
17
*****************************************************************/
18
18
19
- int main (int argc, const char **argv) {
20
- // CLI11_PARSE(app, argc, argv);
21
-
22
- if (argc != 3 ) {
23
- std::cerr << " chump_doc must have two args: path to manifest directory and "
24
- " output dir"
25
- << std::endl;
26
- return -1 ;
27
- }
28
-
29
- fs::path packages_path = argv[1 ];
30
- fs::path packages_subdir = packages_path / " packages" ;
31
- fs::path output_dir = argv[2 ];
32
-
33
- if (!fs::exists (packages_subdir) || !fs::is_directory (packages_subdir)) {
34
- std::cout << " no 'packages' dir found in " << packages_path
35
- << " make sure you pointed to the chump-packages repo correctly"
36
- << std::endl;
37
- return -1 ;
38
- }
39
- if (!fs::exists (output_dir)) {
40
- std::cout << " output dir '" << output_dir << " ' not found" << std::endl;
41
- return -1 ;
42
- }
43
-
44
- std::vector<Package> packages;
45
-
46
- for (auto const &path : fs::directory_iterator{packages_subdir}) {
47
- if (!fs::is_directory (path))
48
- continue ;
49
-
50
- // Each directory corresponds to a package
51
-
52
- // grab the package.json
53
- fs::path pkg_path = path.path () / " package.json" ;
54
-
55
- // std::cout << pkg_path << std::endl;
56
-
57
- if (!fs::exists (pkg_path)) {
58
- std::cerr
59
- << " Package definition " << pkg_path
60
- << " not found, are you in the chump-packages/packages directory?"
61
- << std::endl;
62
- continue ;
19
+ int main ( int argc, const char ** argv )
20
+ {
21
+ if ( argc != 3 ) {
22
+ std::cerr << " chump_doc must have two args: path to manifest directory and "
23
+ " output dir"
24
+ << std::endl;
25
+ return -1 ;
63
26
}
64
27
65
- Package pkg = read_package (pkg_path);
28
+ fs::path packages_path = argv[1 ];
29
+ fs::path packages_subdir = packages_path / " packages" ;
30
+ fs::path output_dir = argv[2 ];
66
31
67
- populate_versions (&pkg, path);
32
+ if ( !fs::exists ( packages_subdir ) || !fs::is_directory ( packages_subdir ) ) {
33
+ std::cout << " no 'packages' dir found in " << packages_path
34
+ << " make sure you pointed to the chump-packages repo correctly"
35
+ << std::endl;
36
+ return -1 ;
37
+ }
38
+ if ( !fs::exists ( output_dir ) ) {
39
+ std::cout << " output dir '" << output_dir << " ' not found" << std::endl;
40
+ return -1 ;
41
+ }
68
42
69
- packages.push_back (pkg);
70
- }
43
+ std::vector<Package> packages;
71
44
72
- PackageList package_list (packages);
45
+ for ( auto const & path : fs::directory_iterator{ packages_subdir } ) {
46
+ if ( !fs::is_directory ( path ) )
47
+ continue ;
73
48
74
- fs::create_directory (output_dir / " packages " );
49
+ // Each directory corresponds to a package
75
50
76
- for (auto const &p : package_list.get_packages ()) {
77
- fs::path filename = p.name + " .html" ;
78
- fs::path pkg_path = output_dir / " packages" / filename;
79
- std::ofstream out (pkg_path);
80
- out << package_doc (p);
81
- out.close ();
82
- }
51
+ // grab the package.json
52
+ fs::path pkg_path = path.path () / " package.json" ;
53
+
54
+ // std::cout << pkg_path << std::endl;
55
+
56
+ if ( !fs::exists ( pkg_path ) ) {
57
+ std::cerr
58
+ << " Package definition " << pkg_path
59
+ << " not found, are you in the chump-packages/packages directory?"
60
+ << std::endl;
61
+ continue ;
62
+ }
63
+
64
+ Package pkg = read_package ( pkg_path );
65
+
66
+ populate_versions ( &pkg, path );
67
+
68
+ packages.push_back ( pkg );
69
+ }
70
+
71
+ PackageList package_list ( packages );
72
+
73
+ fs::create_directory ( output_dir / " packages" );
74
+
75
+ for ( auto const & p : package_list.get_packages () ) {
76
+ fs::path filename = p.name + " .html" ;
77
+ fs::path pkg_path = output_dir / " packages" / filename;
78
+ std::ofstream out ( pkg_path );
79
+ out << package_doc ( p );
80
+ out.close ();
81
+ }
83
82
84
- fs::path idx_path = output_dir / " index.html" ;
85
- std::ofstream out (idx_path);
86
- out << package_idx (package_list);
87
- out.close ();
83
+ fs::path idx_path = output_dir / " index.html" ;
84
+ std::ofstream out ( idx_path );
85
+ out << package_idx ( package_list );
86
+ out.close ();
88
87
}
89
88
90
- string package_doc (Package p) {
91
- std::stringstream ss;
92
-
93
- ss << " <html>" ;
94
- ss << " <title>" << p.name << " </title>" ;
95
- ss << " <body>" ;
96
-
97
- ss << " <h1>" << p.name << " </h1>" ;
98
-
99
- ss << " <p> install command: chump install " << p.name << " </p>" ;
100
-
101
- // ss << "<p> authors: " << p.
102
-
103
- ss << " <p>" << p.description << " </p>" ;
104
-
105
- ss << " <p> Homepage: "
106
- << " <a href=\" " << p.homepage << " \" >" << p.homepage << " </a>"
107
- << " </p>" ;
108
- ;
109
- ss << " <p> Repository: "
110
- << " <a href=\" " << p.repository << " \" >" << p.repository << " </a>"
111
- << " </p>" ;
112
-
113
- ss << " <p> License: " << p.license << " </p>" ;
114
-
115
- // Current versions (mac, windows, linux)
116
- ss << " <p>"
117
- << " Current versions:"
118
- << " </p>" ;
119
-
120
- optional<PackageVersion> linux = p.latest_version (" linux" );
121
- optional<PackageVersion> win = p.latest_version (" windows" );
122
- optional<PackageVersion> mac = p.latest_version (" mac" );
123
-
124
- ss << " <table>" ;
125
- if (linux)
126
- ss << " <tr>"
127
- << " <th>"
128
- << " linux"
129
- << " </th>"
130
- << " <th>" << linux.value ().getVersionString () << " </th>"
131
- << " </tr>" ;
132
- if (win)
133
- ss << " <tr>"
134
- << " <th>"
135
- << " windows"
136
- << " </th>"
137
- << " <th>" << win.value ().getVersionString () << " </th>"
138
- << " </tr>" ;
139
- if (mac)
140
- ss << " <tr>"
141
- << " <th>"
142
- << " mac"
143
- << " </th>"
144
- << " <th>" << mac.value ().getVersionString () << " </th>"
145
- << " </tr>" ;
146
- ss << " </table>" ;
147
-
148
- ss << " </body>" ;
149
- ss << " </html>" ;
150
-
151
- return ss.str ();
89
+ string package_doc ( Package p )
90
+ {
91
+ std::stringstream ss;
92
+
93
+ ss << " <html>" ;
94
+ ss << " <title>" << p.name << " </title>" ;
95
+ ss << " <body>" ;
96
+
97
+ ss << " <h1>" << p.name << " </h1>" ;
98
+
99
+ ss << " <p> install command: chump install " << p.name << " </p>" ;
100
+
101
+ // ss << "<p> authors: " << p.
102
+
103
+ ss << " <p>" << p.description << " </p>" ;
104
+
105
+ ss << " <p> Homepage: "
106
+ << " <a href=\" " << p.homepage << " \" >" << p.homepage << " </a>"
107
+ << " </p>" ;
108
+ ;
109
+ ss << " <p> Repository: "
110
+ << " <a href=\" " << p.repository << " \" >" << p.repository << " </a>"
111
+ << " </p>" ;
112
+
113
+ ss << " <p> License: " << p.license << " </p>" ;
114
+
115
+ // Current versions (mac, windows, linux)
116
+ ss << " <p>"
117
+ << " Current versions:"
118
+ << " </p>" ;
119
+
120
+ optional<PackageVersion> linux = p.latest_version ( " linux" );
121
+ optional<PackageVersion> win = p.latest_version ( " windows" );
122
+ optional<PackageVersion> mac = p.latest_version ( " mac" );
123
+
124
+ ss << " <table>" ;
125
+ if ( linux )
126
+ ss << " <tr>"
127
+ << " <th>"
128
+ << " linux"
129
+ << " </th>"
130
+ << " <th>" << linux.value ().getVersionString () << " </th>"
131
+ << " </tr>" ;
132
+ if ( win )
133
+ ss << " <tr>"
134
+ << " <th>"
135
+ << " windows"
136
+ << " </th>"
137
+ << " <th>" << win.value ().getVersionString () << " </th>"
138
+ << " </tr>" ;
139
+ if ( mac )
140
+ ss << " <tr>"
141
+ << " <th>"
142
+ << " mac"
143
+ << " </th>"
144
+ << " <th>" << mac.value ().getVersionString () << " </th>"
145
+ << " </tr>" ;
146
+ ss << " </table>" ;
147
+
148
+ ss << " </body>" ;
149
+ ss << " </html>" ;
150
+
151
+ return ss.str ();
152
152
}
153
153
154
- string package_idx (PackageList pkg_list) {
155
- std::stringstream ss;
156
-
157
- ss << " <html>" ;
158
- ss << " <title>"
159
- << " ChuMP"
160
- << " </title>" ;
161
- ss << " <body>" ;
162
-
163
- ss << " <h1>"
164
- << " ChuMP (the ChucK Manager of Packages)"
165
- << " </h1>" ;
166
- ss << " <h2>"
167
- << " Package Directory"
168
- << " </h2>" ;
169
-
170
- ss << " <table>" ;
171
- for (auto const &p : pkg_list.get_packages ()) {
172
- ss << " <tr>"
173
- << " <th>"
174
- << " <a href=\" ./packages/" << p.name << " .html\" >" << p.name << " </a>"
175
- << " </th>"
176
- << " <th>" << p.description << " </th>"
177
- << " </tr>" ;
178
- }
179
- ss << " </table>" ;
180
-
181
- return ss.str ();
154
+ string package_idx ( PackageList pkg_list )
155
+ {
156
+ std::stringstream ss;
157
+
158
+ ss << " <html>" ;
159
+ ss << " <title>"
160
+ << " ChuMP"
161
+ << " </title>" ;
162
+ ss << " <body>" ;
163
+
164
+ ss << " <h1>"
165
+ << " ChuMP (the ChucK Manager of Packages)"
166
+ << " </h1>" ;
167
+ ss << " <h2>"
168
+ << " Package Directory"
169
+ << " </h2>" ;
170
+
171
+ ss << " <table>" ;
172
+ for ( auto const & p : pkg_list.get_packages () ) {
173
+ ss << " <tr>"
174
+ << " <th>"
175
+ << " <a href=\" ./packages/" << p.name << " .html\" >" << p.name << " </a>"
176
+ << " </th>"
177
+ << " <th>" << p.description << " </th>"
178
+ << " </tr>" ;
179
+ }
180
+ ss << " </table>" ;
181
+
182
+ return ss.str ();
182
183
}
0 commit comments