A D package containing my single-file modules
Revision | 75aeabe2d9b70e454de027da0ad404a2697c748b (tree) |
---|---|
Time | 2023-03-25 21:24:57 |
Author | nemophila <stigma+osdn@disr...> |
Commiter | nemophila |
directories: Documentation for ProjectDirectories
@@ -205,6 +205,13 @@ struct BaseDirectories | ||
205 | 205 | } |
206 | 206 | |
207 | 207 | /// |
208 | +/// Returns a new instance of `BaseDirectories`. | |
209 | +/// | |
210 | +/// The instance is an immutable snapshop of the state of the system at | |
211 | +/// the time this function is called. Subsequent changes to the state | |
212 | +/// of the system are not reflected in instances created prior to such | |
213 | +/// a change. | |
214 | +/// | |
208 | 215 | nothrow BaseDirectories getBaseDirectories() |
209 | 216 | { |
210 | 217 | // OS X first so it doesn't get mixed with Posix. |
@@ -253,17 +260,207 @@ unittest | ||
253 | 260 | } |
254 | 261 | |
255 | 262 | /// |
263 | +/// `ProjectDirectories ` computes the location of cache, config, or | |
264 | +/// data directories for a specific application, which are derived from | |
265 | +/// the standard directories and the name of the project/organisation. | |
266 | +/// | |
267 | +/// ## Examples | |
268 | +/// | |
269 | +/// All examples in this section are computed with a user named *Elq*, | |
270 | +/// and a `ProjectDirectories` instance created with the following | |
271 | +/// information: | |
272 | +/// | |
273 | +/// ```d | |
274 | +/// ProjectDirectories projectDirs = getProjectDirectories("com", "Foo Corp", "Bar App"); | |
275 | +/// ``` | |
276 | +/// | |
277 | +/// Example of `ProjectDirectories#configDir` value in different | |
278 | +/// operating systems: | |
279 | +/// | |
280 | +/// $(UL | |
281 | +/// $(LI $(B Posix): `/home/elq/.config/barapp`) | |
282 | +/// $(LI $(B macOS): $(RED Platform not supported)) | |
283 | +/// $(LI $(B Windows): `C:\Users\Elq\AppData\Roaming\Foo Corp\Bar App\config`) | |
284 | +/// ) | |
285 | +/// | |
256 | 286 | struct ProjectDirectories |
257 | 287 | { |
288 | + /// | |
289 | + /// The path to the project's cache directory in which | |
290 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
291 | + /// | |
292 | + /// $(TABLE | |
293 | + /// $(TR | |
294 | + /// $(TH Platform) | |
295 | + /// $(TH Value) | |
296 | + /// $(TH Example) | |
297 | + /// ) | |
298 | + /// $(TR | |
299 | + /// $(TD Posix) | |
300 | + /// $(TD `$XDG_CACHE_HOME/<project_path>` (fallback: `$HOME/.cache/<project_path>`)) | |
301 | + /// $(TD /home/elq/.cache/barapp) | |
302 | + /// ) | |
303 | + /// $(TR | |
304 | + /// $(TD macOS) | |
305 | + /// $(TD $(RED Platform not supported)) | |
306 | + /// $(TD $(RED Platform not supported)) | |
307 | + /// ) | |
308 | + /// $(TR | |
309 | + /// $(TD Windows) | |
310 | + /// $(TD `FOLDERID_LocalAppData\<project_path>\cache`) | |
311 | + /// $(TD C:\Users\Elq\AppData\Local\Foo Corp\Bar App\cache ) | |
312 | + /// ) | |
313 | + /// ) | |
314 | + /// | |
258 | 315 | immutable string cacheDir; |
316 | + | |
317 | + /// | |
318 | + /// The path to the project's configuration directory, in which | |
319 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
320 | + /// | |
321 | + /// $(TABLE | |
322 | + /// $(TR | |
323 | + /// $(TH Platform) | |
324 | + /// $(TH Value) | |
325 | + /// $(TH Example) | |
326 | + /// ) | |
327 | + /// $(TR | |
328 | + /// $(TD Posix) | |
329 | + /// $(TD `$XDG_CONFIG_HOME/<project_path>` (fallback: `$HOME/.config/<project_path>/`)) | |
330 | + /// $(TD /home/elq/.config/barapp) | |
331 | + /// ) | |
332 | + /// $(TR | |
333 | + /// $(TD macOS) | |
334 | + /// $(TD $(RED Platform not supported)) | |
335 | + /// $(TD $(RED Platform not supported)) | |
336 | + /// ) | |
337 | + /// $(TR | |
338 | + /// $(TD Windows) | |
339 | + /// $(TD `FOLDERID_RoamingAppData\<project_path>\config`) | |
340 | + /// $(TD C:\Users\Elq\AppData\Roaming\Foo Corp\Bar App\config ) | |
341 | + /// ) | |
342 | + /// ) | |
343 | + /// | |
259 | 344 | immutable string configDir; |
345 | + | |
346 | + /// | |
347 | + /// The path to the project's data directory, in which | |
348 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
349 | + /// | |
350 | + /// $(TABLE | |
351 | + /// $(TR | |
352 | + /// $(TH Platform) | |
353 | + /// $(TH Value) | |
354 | + /// $(TH Example) | |
355 | + /// ) | |
356 | + /// $(TR | |
357 | + /// $(TD Posix) | |
358 | + /// $(TD `$XDG_DATA_HOME/<project_path>` (fallback: `$HOME/.local/share/<project_path>/`)) | |
359 | + /// $(TD /home/elq/.local/share/barapp) | |
360 | + /// ) | |
361 | + /// $(TR | |
362 | + /// $(TD macOS) | |
363 | + /// $(TD $(RED Platform not supported)) | |
364 | + /// $(TD $(RED Platform not supported)) | |
365 | + /// ) | |
366 | + /// $(TR | |
367 | + /// $(TD Windows) | |
368 | + /// $(TD `FOLDERID_RoamingAppData\<project_path>\data`) | |
369 | + /// $(TD C:\Users\Elq\AppData\Roaming\Foo Corp\Bar App\data ) | |
370 | + /// ) | |
371 | + /// ) | |
372 | + /// | |
260 | 373 | immutable string dataDir; |
374 | + | |
375 | + /// | |
376 | + /// The path to the project's local data directory, in which | |
377 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
378 | + /// | |
379 | + /// $(TABLE | |
380 | + /// $(TR | |
381 | + /// $(TH Platform) | |
382 | + /// $(TH Value) | |
383 | + /// $(TH Example) | |
384 | + /// ) | |
385 | + /// $(TR | |
386 | + /// $(TD Posix) | |
387 | + /// $(TD `$XDG_DATA_HOME/<project_path>` (fallback: `$HOME/.local/share/<project_path>/`)) | |
388 | + /// $(TD /home/elq/.local/share/barapp) | |
389 | + /// ) | |
390 | + /// $(TR | |
391 | + /// $(TD macOS) | |
392 | + /// $(TD $(RED Platform not supported)) | |
393 | + /// $(TD $(RED Platform not supported)) | |
394 | + /// ) | |
395 | + /// $(TR | |
396 | + /// $(TD Windows) | |
397 | + /// $(TD `FOLDERID_LocalAppData\<project_path>\data`) | |
398 | + /// $(TD C:\Users\Elq\AppData\Local\Foo Corp\Bar App\data ) | |
399 | + /// ) | |
400 | + /// ) | |
401 | + /// | |
261 | 402 | immutable string dataLocalDir; |
403 | + | |
404 | + /// | |
405 | + /// The path to the project's preference directory, in which | |
406 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
407 | + /// | |
408 | + /// $(TABLE | |
409 | + /// $(TR | |
410 | + /// $(TH Platform) | |
411 | + /// $(TH Value) | |
412 | + /// $(TH Example) | |
413 | + /// ) | |
414 | + /// $(TR | |
415 | + /// $(TD Posix) | |
416 | + /// $(TD `$XDG_CONFIG_HOME/<project_path>` (fallback: `$HOME/.config/<project_path>/`)) | |
417 | + /// $(TD /home/elq/.config/barapp) | |
418 | + /// ) | |
419 | + /// $(TR | |
420 | + /// $(TD macOS) | |
421 | + /// $(TD $(RED Platform not supported)) | |
422 | + /// $(TD $(RED Platform not supported)) | |
423 | + /// ) | |
424 | + /// $(TR | |
425 | + /// $(TD Windows) | |
426 | + /// $(TD `FOLDERID_RoamingAppData\<project_path>\config`) | |
427 | + /// $(TD C:\Users\Elq\AppData\Roaming\Foo Corp\Bar App\config) | |
428 | + /// ) | |
429 | + /// ) | |
430 | + /// | |
262 | 431 | immutable string preferenceDir; |
432 | + | |
433 | + /// | |
434 | + /// The path to the project's data directory, in which | |
435 | + /// `<project_path>` is the value of `ProjectDirectories#projectPath`. | |
436 | + /// | |
437 | + /// $(TABLE | |
438 | + /// $(TR | |
439 | + /// $(TH Platform) | |
440 | + /// $(TH Value) | |
441 | + /// $(TH Example) | |
442 | + /// ) | |
443 | + /// $(TR | |
444 | + /// $(TD Posix) | |
445 | + /// $(TD `$XDG_RUNTIME_DIR`) | |
446 | + /// $(TD /run/user/1001/bareapp) | |
447 | + /// ) | |
448 | + /// $(TR | |
449 | + /// $(TD macOS) | |
450 | + /// $(TD $(RED Platform not supported)) | |
451 | + /// $(TD $(RED Platform not supported)) | |
452 | + /// ) | |
453 | + /// $(TR | |
454 | + /// $(TD Windows) | |
455 | + /// $(TD $(RED Platform not supported)) | |
456 | + /// $(TD $(RED Platform not supported)) | |
457 | + /// ) | |
458 | + /// ) | |
459 | + /// | |
263 | 460 | immutable string runtimeDir; |
264 | 461 | |
265 | 462 | /// |
266 | - /// Returns the project path fragment used to compute the project's | |
463 | + /// The project path fragment used to compute the project's | |
267 | 464 | /// cache/config/data directories. |
268 | 465 | /// |
269 | 466 | /// The value is derived from the arguments provided to the |
@@ -293,6 +490,28 @@ struct ProjectDirectories | ||
293 | 490 | } |
294 | 491 | |
295 | 492 | /// |
493 | +/// Return an instance of `ProjectDirectories` from values describing | |
494 | +/// the project. | |
495 | +/// | |
496 | +/// Params: | |
497 | +/// qualifier = The reverse domain name notation of the application, | |
498 | +/// excluding the organisation or application name itself. $(BR) | |
499 | +/// An example string can be passed if no qualifier should | |
500 | +/// be used (only affects macOS). $(BR) | |
501 | +/// Example values: `"com.example"`, `"org"`, `"co.uk"`, `""`. | |
502 | +/// | |
503 | +/// organisation = The name of the organisation that develops this application, | |
504 | +/// or for which the application is developed.$(BR) | |
505 | +/// An empty string can be passed if no organisation should be | |
506 | +/// used (only affects macOS and Windows).$(BR) | |
507 | +/// Example values: `"Foo Corp"`, `"Alice and Bob Inc"`, `""`. | |
508 | +/// | |
509 | +/// application = The name of the application itself.$(BR) | |
510 | +/// Example values: `"Bar App"`, `"ExampleProgram"`, `"Unicorn-Programme"`. | |
511 | +/// | |
512 | +/// Returns: An instance of `ProjectDirectories`, whose directory field values are | |
513 | +/// based on the `qualifier`, `organisation`, and `application` arguments. | |
514 | +/// | |
296 | 515 | ProjectDirectories getProjectDirectories(string qualifier, string organisation, string application) nothrow |
297 | 516 | in |
298 | 517 | { |