Skip to content

Commit bd8190b

Browse files
committed
update documentation
1 parent 572a5e1 commit bd8190b

1 file changed

Lines changed: 96 additions & 46 deletions

File tree

README.md

Lines changed: 96 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ DependencyControl provides versioning, automatic script update, dependency manag
55

66
__Features__:
77

8-
* Loads modules used by an automation script, pulls missing requirements from the internet and informs the user about missing and outdated modules that could not be updated automatically.
8+
* A lightweight package manager lets users conveniently install scripts right from inside Aegisub
9+
* Loads modules used by an automation script, pulls missing requirements from the internet and informs the user about missing and outdated modules that could not be updated automatically
910
* Checks scripts and modules for updates and automatically installs them
1011
* Offers convenient macro registration with user-customizable submenus
11-
* Provides configuration and logging services for your script
12+
* Provides configuration, logging services, file operations and a unit test framework for your scripts
1213
* Supports optional modules and private module copies for cases where an older or custom version of a module is required
1314
* Resolves circular dependencies (limitations apply)
1415

1516
__Requirements__:
1617

17-
* Aegisub 3.2.0+
18+
* Aegisub > 3.2.0 (e.g. [Plorkyeran's](http://plorkyeran.com/aegisub/) r8792+ or [my](http://files.line0.eu/builds/Aegisub/) git builds)
1819
* [LuaJSON](https://github.com/harningt/luajson)
19-
* [DownloadManager](https://github.com/torque/ffi-experiments/releases) v0.1.2
20-
* [PreciseTimer](https://github.com/torque/ffi-experiments/releases) v0.1.2
20+
* [DownloadManager](https://github.com/torque/ffi-experiments/releases) v0.3.0
21+
* [BadMutex](https://github.com/torque/ffi-experiments/releases) v0.1.2
22+
* [PreciseTimer](https://github.com/torque/ffi-experiments/releases) v0.1.4
2123

2224
----------------------------------
2325

@@ -28,7 +30,11 @@ __Requirements__:
2830
3. [Namespaces and Paths](#namespaces-and-paths)
2931
4. [The Anatomy of an Updater Feed](#the-anatomy-of-an-updater-feed)
3032
5. [Reference](#reference)
31-
6. [Ancillary Components: Logger and ConfigHandler](#FIXME) (tbd)
33+
1. [DependencyControl](#FIXME)
34+
2. [Updater](#FIXME)
35+
3. [Logger](#FIXME)
36+
4. [ConfigHandler](#FIXME)
37+
5. [FileOps](#FIXME)
3238

3339
----------------------------------
3440

@@ -38,6 +44,7 @@ As an end-user you don't get to decide whether your scripts use DependencyContro
3844

3945
#### Install Instructions ####
4046
1. Download the latest DependencyControl release for your platform and unpack its contents to your Aegisub **user** automation directory.
47+
Alternatively use one of the [provided Aegisub builds](http://files.line0.eu/builds/Aegisub/) with built-in DependencyControl.
4148

4249
_It is essential DependencyControl and all scripts it's used reside in the **user** automation directory, **NOT** the the automation directory in the Aegisub application folder._
4350

@@ -115,7 +122,8 @@ local version = DependencyControl{
115122
local util, LineCollection, Line, Log, ASS, Common, YUtils = version:requireModules()
116123
```
117124

118-
Specifying a feed in your own version record provides DepedencyControl with a source to download updates to your script from. Specifying feeds for required modules managed by DependencyControl allows the Updater to discover those modules and fetch them when they're missing from the user's computer.
125+
Specifying a feed in your own version record provides DepedencyControl with a source to download updates to your script from.
126+
Specifying feeds for required modules managed by DependencyControl allows the Updater to discover those modules and fetch them when they're missing from the user's computer. However, you can omit the feed URLs for required modules when your own feed already has references to them.
119127

120128

121129
To __register your macros__ use the following code snippets instead of the usual *aegisub.register_macro()* calls:
@@ -208,12 +216,15 @@ Examples:
208216
* l0.ASSWipe.lua
209217
* l0.ASSWipe.Addon.moon
210218

211-
__Modules__ use the `?user/automation/include` folder, which has a nested file structure. To determine your _subdirectory/file base name_, the dots in your namespace are replaced with `/` (`\` in Windows terms).
219+
__Modules__ use the `?user/automation/include` folder, which has a nested file structure. To determine your _subdirectory/file base name_, the dots in your namespace are replaced with `/` (`\` in Windows terms).
220+
221+
__Tests__ use the `?user/automation/tests/DepUnit/modules` or `?user/automation/tests/DepUnit/macros` folder depending on whether a macro or automation is being tested and mirror the directory structure of the respective `include` and `autoload` folders.
212222

213223
Our example module ASSFoundation with namespace __l0.ASSFoundation__ writes (among others) the following files:
214224
* __?user/automation/include/l0/ASSFoundation__.lua
215225
* __?user/automation/include/l0/ASSFoundation__/ClassFactory.lua
216226
* __?user/automation/include/l0/ASSFoundation__/Draw/Bezier.lua
227+
* __?user/automation/tests/modules/l0/ASSFoundation__.lua
217228

218229
---------------------------------------------
219230

@@ -225,12 +236,17 @@ If you want DepedencyControl auto-update your script on the user's system, you'l
225236

226237
`````javascript
227238
{
228-
"dependencyControlFeedFormatVersion": "0.1.0",
229-
// The version of the feed format. The current version is 0.1.0, don't touch this until further notice.
239+
"dependencyControlFeedFormatVersion": "0.3.0",
240+
// The version of the feed format. The current version is 0.3.0, don't touch this until further notice.
230241
"name": "line0's Aegisub Scripts",
231242
"description": "Main repository for all of line0's automation macros.",
232243
"maintainer": "line0",
233244
// The title and description of your repository as well as the name of the maintainer. May be used by GUI-driven management tools, package managers, etc...
245+
"knownFeeds": {
246+
"a-mo": "https://raw.githubusercontent.com/TypesettingCartel/Aegisub-Motion/DepCtrl/DependencyControl.json",
247+
"ASSFoundation": "https://raw.githubusercontent.com/TypesettingTools/ASSFoundation/master/DependencyControl.json"
248+
},
249+
// A hashtable of known feed URLs. Can be referenced with @{feed:name} and will be used to discover other repositories the user can install automation scripts and modules from. At the very least this should contain the repo URLs for the required modules in your repo, but may be used to adverise other unrelated repos you trust.
234250
"baseUrl": "https://github.com/TypesettingCartel/line0-Aegisub-Scripts",
235251
// baseUrl is a template variable that can be referenced in other string fields of the template. It's useful when you have several scripts which all have their documentation hosted on the same site (so they start with the same URL). For more Information about templates, see the section below.
236252
"url": "@{baseUrl}",
@@ -295,6 +311,14 @@ An automation script or module object looks like this:
295311
// against the downloaded file, so it must always be present and valid or the update process
296312
// will fail on the user's end.
297313
},
314+
{
315+
"name": ".lua",
316+
"type": "test",
317+
// Optional, defaults to "script". Specify "test" to denote a unit test.
318+
// Currently only "script" and "test" are available, unknown script types will be skipped.
319+
"url": "@{fileBaseUrl}.Tests.lua",
320+
"sha1": "27745AB9CF04A840CF3454050CA9D38FA345CEBB"
321+
},
298322
{
299323
"name": ".Helper.dll",
300324
"url": "@{fileBaseUrl}@{fileName}",
@@ -312,14 +336,15 @@ An automation script or module object looks like this:
312336
"moduleName": "a-mo.LineCollection",
313337
"name": "Aegisub-Motion (LineCollection)",
314338
"url": "https://github.com/torque/Aegisub-Motion",
315-
"version": "1.0.1"
339+
"version": "1.0.1",
340+
"feed": "@{feed:a-mo}"
316341
},
317342
{
318343
"moduleName": "l0.ASSFoundation",
319344
"name": "ASSFoundation",
320345
"url": "https://github.com/TypesettingCartel/ASSFoundation",
321346
"version": "0.1.1",
322-
"feed": "https://raw.githubusercontent.com/TypesettingCartel/ASSFoundation/master/DependencyControl.json"
347+
"feed": "@{feed:ASSFoundation}"
323348
},
324349
{
325350
"moduleName": "aegisub.util"
@@ -355,7 +380,8 @@ Variables extracted at the **same depth** are expanded in a specific order. As a
355380
356381
_Depth 1:_ Feed Information
357382
1. __feedName__: The name of the feed
358-
2. __baseUrl__: The baseUrl field
383+
2. __baseUrl__: The baseUrl field
384+
3. __feed:###__: A reference to a feed URL in the knownFeeds table
359385
360386
_Depth 3:_ Script Information
361387
1. __namespace__: the script namespace
@@ -381,6 +407,10 @@ For an example to serve updates from the HEAD of a GitHub repository, see [here]
381407
382408
### Reference ###
383409
410+
This section is currently both incomplete and outdated. Sorry about that.
411+
412+
#### DependencyControl ####
413+
384414
__DependencyControl{*tbl* [requiredModules]={}, *str* :name=script_name, *str* :description=script_description, *str* :author=script_author, *str* :url, *str* :version, *str* :moduleName, *str* [:configFile], *string* [:namespace]} --> *obj* DependecyControlRecord__
385415
386416
The constructor for a DepedencyControl record. Uses the table-based signature.
@@ -401,23 +431,15 @@ __Arguments:__
401431
* _feed_: The update feed for your script.
402432
* _configFile_: Configuration file base name used by the script. Defaults to the namespace. Used for configuration services and script management purposes.
403433
404-
#### Methods ####
405-
__:checkVersion(*str/num* version) --> *bool* moduleUpToDate, *str* error__
434+
##### Methods #####
435+
__:checkVersion(*str/num* version, *str* [precision = "patch"]) --> *bool* moduleUpToDate, *str* error__
406436
407-
Returns true if the version number of the record is greater than or equal to __version__. If the version can't be parsed it returns nil and and error message.
437+
Returns true if the version number of the record is greater than or equal to __version__. Reduce the __precision__ to `minor` or `major` to also return true for lower patch or minor versions respecitively. If the version can't be parsed it returns nil and and error message.
408438
409439
__:checkOptionalModules(*tbl* modules) --> *bool* result, *str* errorMessage__
410440
411441
Returns true if the optional __modules__ have been loaded, where __modules__ is a list of module names. If one or more of the modules are missing it returns false and an error message.
412442
413-
__:createDir(*str* path, *bool* [isFile]) --> *bool* result, *str* error__
414-
415-
Creates a directory. Returns _true_ on success or if the directory already exists or _false_ and an error message on failure. Use __isFile__ to indicate the __path__ points to a file, in which case its parent will be created.
416-
417-
__:expandFeed(*tbl* feed) --> *tbl* feed__
418-
419-
Expands template variables in downloaded update feeds **in-place** and returns the expanded feed. _Intended for internal use._
420-
421443
__:getConfigFileName() --> *str* fileName__
422444
423445
Returns a full path to the config file proposed for this script by DependencyControl. Uses the configFile argument passed to the constructor which defaults to the script namespace. The path is subject to user configuration and defaults to "?user\config". The file ending is always .json, because why would you use any other format?
@@ -432,23 +454,6 @@ __:getLogger(*tbl* args) => *obj* Logger__
432454
433455
Returns a Logger (see [Logger Documentation](#FIXME)) preconfigured for this script. Trace level and config file preference default to user-configurable values. Log file name and prefix are based on namespace and script name.
434456
435-
__:getUpdaterErrorMsg(*int* [code], *str* targetName, ...) --> *str* errorMsg__
436-
437-
Used to turn an updater return __code__ into a human-readable error message. The __name__ of the updated component and other format string parameters are passed into the function.
438-
439-
VarArgs:
440-
441-
1. __*bool* isModule__: True when component is a module, false when it is an automation script/macro
442-
2. __*bool* isFetch__: True when we are fetching a missing module, false when updating
443-
3. __extError__: Extended error information as returned by the _:update()_ method
444-
445-
__:getUpdaterLock(*bool* [doWait], *int* [waitTimeout=(user config)]) --> *bool* result, *str* runningHost__
446-
447-
Locks the updater to the current macro/environment. Since all automation scripts load in parallel we have to make sure multiple automation scripts don't all update/fetch the same depedencies at once multiple times. The solution is to only let one updater operate at a time. The others will wait their turn and recheck if their required modules were fetched in the meantime.
448-
449-
If __doWait__ is true, the function will wait until the updater is unlocked or __waitTimeout__ has passed. It will then get the lock and return true. If __doWait__ is false, the function will return immediately (true on success, false if another updater has the lock). _Intendend for internal use_.
450-
451-
452457
__:getVersionNumber(*str/num* versionString) --> *int/bool* version, *str* error__
453458
454459
Takes a SemVer string and converts it into a version number. If parsing the version string fails it returns false and an error message instead.
@@ -476,9 +481,10 @@ __:moveFile(*str* src, *str* dest) --> *bool* success, *str* error__
476481
477482
Moves a file from __source__ to __destiantion__ (where both are full file names). Returns true on success or false and error message on failure.
478483
479-
__:register(*tbl* selfRef) --> *tbl* selfRef__
484+
__:register(*tbl* selfRef, extraUnitTestArgs...) --> *tbl* selfRef__
480485
481486
Replaces dummy reference written to the global LOADED_MODULES table at DependencyControl object creation time with a reference to this module.
487+
Also automatically registers unit tests for this module, passing in any __extraUnitTestArgs__
482488
483489
The purpose of this construct is to allow circular references between modules. Limitations apply: the modules in question may not use each other during construction/setup of each module (for obvious reasons).
484490
@@ -502,9 +508,9 @@ __:registerMacros(*tbl* macros, *bool* [useSubmenuDefault=true])__
502508
Registers multiple macros, where __macros__ is a list of tables containing the arguments to a __:registerMacro()__ call for each automation menu entry. a single macro using script name and description by default.
503509
If __useSubmenuDefault__ is set to true, the macros will be placed in a submenu using the script name unless overriden by per-macro settings.
504510
505-
__:releaseUpdaterLock()__
511+
__:registerTests(unitTestArgs...)__
506512
507-
Makes an updater host (macro) release its lock on the Updater if it has one. See _:getUpdaterLock_ for more information
513+
Registers unit tests for automation modules, passing in any of specified __unitTestArgs__. Registration of modules is done automatically upon calling __:register__
508514
509515
__:requireModules([modules=@requiredModules], *bool* [forceUpdate], *bool* [updateMode], *tbl* [addFeeds={@feed})] --> ...__
510516
@@ -514,6 +520,34 @@ The updater will try to download copies of modules that are missing or outdated
514520
515521
Use __forceUpdate__ to override update intervals and perform update checks for all required modules, even if requirements are satisfied.
516522
523+
__:writeConfig(*bool* [writeLocal=true], *bool* [writeGlobal=true], *bool* [concert]]__
524+
525+
Writes __global__ and per-module __local__ configuration. If __concert__ is true, concerted writing will be used to update the configuration of all DependencyControl hosted by any given macro/environment at once. See ConfigHandler documentation for more information. _Intended for internal use._
526+
527+
#### Updater #####
528+
529+
##### Methods #####
530+
531+
__:getUpdaterErrorMsg(*int* [code], *str* targetName, ...) --> *str* errorMsg__
532+
533+
Used to turn an updater return __code__ into a human-readable error message. The __name__ of the updated component and other format string parameters are passed into the function.
534+
535+
VarArgs:
536+
537+
1. __*bool* isModule__: True when component is a module, false when it is an automation script/macro
538+
2. __*bool* isFetch__: True when we are fetching a missing module, false when updating
539+
3. __extError__: Extended error information as returned by the _:update()_ method
540+
541+
__:getUpdaterLock(*bool* [doWait], *int* [waitTimeout=(user config)]) --> *bool* result, *str* runningHost__
542+
543+
Locks the updater to the current macro/environment. Since all automation scripts load in parallel we have to make sure multiple automation scripts don't all update/fetch the same depedencies at once multiple times. The solution is to only let one updater operate at a time. The others will wait their turn and recheck if their required modules were fetched in the meantime.
544+
545+
If __doWait__ is true, the function will wait until the updater is unlocked or __waitTimeout__ has passed. It will then get the lock and return true. If __doWait__ is false, the function will return immediately (true on success, false if another updater has the lock). _Intendend for internal use_.
546+
547+
__:releaseUpdaterLock()__
548+
549+
Makes an updater host (macro) release its lock on the Updater if it has one. See _:getUpdaterLock_ for more information
550+
517551
__:update(*bool* [force], *tbl* [addFeeds], *bool* [tryAllFeeds=auto]) --> *int* resultCode, *str* extError__
518552
519553
Runs the updater on this automation script or module. This includes recursicely updating all required modules. When __force__ is true, required modules will skip their update interval check.
@@ -522,6 +556,22 @@ By default, the updater will process all suitable feeds until one feed confirms
522556
523557
Returns a result code (0: up-to-date, 1: update performed, <=-1: error) and extendend error information which can be fed into _:getUpdaterErrorMsg()_ to get a descriptive error message.
524558
525-
__:writeConfig(*bool* [writeLocal=true], *bool* [writeGlobal=true], *bool* [concert]]__
559+
#### Logger ####
526560
527-
Writes __global__ and per-module __local__ configuration. If __concert__ is true, concerted writing will be used to update the configuration of all DependencyControl hosted by any given macro/environment at once. See ConfigHandler documentation for more information. _Intended for internal use._
561+
tbd
562+
563+
#### ConfigHandler ####
564+
565+
tbd
566+
567+
#### FileOps ####
568+
569+
tbd
570+
571+
#### UnitTestSuite ####
572+
573+
Reference documentation for the UnitTestSuite module is available in the [source code](https://github.com/TypesettingTools/DependencyControl/blob/master/modules/DependencyControl/UnitTestSuite.moon#L760)
574+
575+
#### UpdateFeed ####
576+
577+
tbd

0 commit comments

Comments
 (0)