|
1 | | -= ISO/TC 211 XML Schemas |
| 1 | += ISO/TC 211 Schemas |
2 | 2 |
|
3 | | -image:https://github.com/ISO-TC211/schemas/workflows/build/badge.svg["XSD documentation build status", link="https://github.com/ISO-TC211/schemas/actions?workflow=build"] |
| 3 | +image:https://github.com/ISO-TC211/schemas/workflows/build/badge.svg["Documentation build status", link="https://github.com/ISO-TC211/schemas/actions?workflow=build"] |
4 | 4 |
|
5 | 5 | image:https://github.com/ISO-TC211/schemas/workflows/deploy/badge.svg["Deploy status", link="https://github.com/ISO-TC211/schemas/actions?workflow=deploy"] |
6 | 6 |
|
| 7 | + |
7 | 8 | == Introduction |
8 | 9 |
|
9 | | -This is the official repository of ISO/TC 211 XML Schemas. |
| 10 | +This is the official repository of ISO/TC 211 Schemas, jointly managed by |
| 11 | +ISO/TC 211/XMG and Ribose. |
| 12 | + |
| 13 | +== Requirements |
| 14 | + |
| 15 | +* Dependencies installation (choose one): |
| 16 | + - Individual: `gem install thor rake` |
| 17 | + - Using Bundler: `bundle install` |
| 18 | + - Build and install gem: `gem build hrma.gemspec && gem install hrma-*.gem` |
| 19 | +* External dependencies: |
| 20 | + - Java (for generating diagrams) |
| 21 | + - xsltproc (for generating documentation) |
| 22 | + |
| 23 | + |
| 24 | +== Command-line reference |
| 25 | + |
| 26 | +=== General |
| 27 | + |
| 28 | +The repository includes a command-line tool called `hrma` (Harmonized Resources |
| 29 | +Maintenance Agency) to manage schemas and generate documentation. |
| 30 | + |
| 31 | + |
| 32 | +=== Schema management |
| 33 | + |
| 34 | +The `schemas` command manages the schema manifest file (`schemas.yml`), which |
| 35 | +controls which schemas should generate documentation. |
| 36 | + |
| 37 | +[source,sh] |
| 38 | +---- |
| 39 | +bundle exec hrma schemas manifest SUBCOMMAND |
| 40 | +---- |
| 41 | + |
| 42 | +Available subcommands: |
| 43 | + |
| 44 | +* `update` - Update schemas.yml with all 3-character XSD and JSON files |
| 45 | +* `list` - List all schemas in the manifest file |
| 46 | +** `--type TYPE` - Filter by schema type (xsd or json) |
| 47 | +** `--doc DOC` - Filter by document number |
| 48 | +* `validate` - Verify all schemas in the manifest exist |
| 49 | + |
| 50 | +[example] |
| 51 | +==== |
| 52 | +[source,sh] |
| 53 | +---- |
| 54 | +# Update schemas.yml with all 3-character XSD and JSON files |
| 55 | +bundle exec hrma schemas manifest update |
| 56 | +
|
| 57 | +# List all schemas in the manifest file |
| 58 | +bundle exec hrma schemas manifest list |
10 | 59 |
|
11 | | -Jointly managed by ISO/TC 211/XMG and Ribose. |
| 60 | +# List only XSD schemas |
| 61 | +bundle exec hrma schemas manifest list --type xsd |
12 | 62 |
|
| 63 | +# List schemas for document 19115 |
| 64 | +bundle exec hrma schemas manifest list --doc 19115 |
13 | 65 |
|
14 | | -== XSD documentation pages |
| 66 | +# Verify all schemas in the manifest exist |
| 67 | +bundle exec hrma schemas manifest validate |
| 68 | +---- |
| 69 | +==== |
| 70 | + |
| 71 | +=== Documentation generation |
| 72 | + |
| 73 | +The `build` command generates documentation for schemas defined in the manifest file. |
| 74 | + |
| 75 | +[source,sh] |
| 76 | +---- |
| 77 | +bundle exec hrma build SUBCOMMAND [OPTIONS] |
| 78 | +---- |
| 79 | + |
| 80 | +Available subcommands: |
| 81 | + |
| 82 | +* `documentation` - Generate documentation for schemas |
| 83 | +** `--manifest-path PATH` - Path to schemas.yml manifest file |
| 84 | +** `--cache-dir DIR` - Directory for caching downloaded tools |
| 85 | +** `--log-dir DIR` - Directory for storing log files |
| 86 | +** `--parallel` / `--no-parallel` - Enable/disable parallel processing with Fractors (default: enabled) |
| 87 | +** `--workers NUM` - Number of parallel workers to use (default: auto-configured) |
| 88 | +* `clean` - Remove generated documentation |
| 89 | +* `distclean` - Remove generated documentation and downloaded tools |
| 90 | +** `--global-cache` - Also clean the global cache directory |
| 91 | + |
| 92 | +Examples: |
15 | 93 |
|
16 | | -XSD documentation pages are generated using the `build` workflow. |
| 94 | +[source,sh] |
| 95 | +---- |
| 96 | +# Generate documentation for schemas |
| 97 | +bundle exec hrma build documentation |
| 98 | +
|
| 99 | +# Generate documentation with custom manifest file |
| 100 | +bundle exec hrma build documentation --manifest-path=custom-schemas.yml |
| 101 | +
|
| 102 | +# Generate documentation with 4 workers |
| 103 | +bundle exec hrma build documentation --workers=4 |
| 104 | +
|
| 105 | +# Generate documentation without parallel processing |
| 106 | +bundle exec hrma build documentation --no-parallel |
17 | 107 |
|
18 | | -The `schemas.yml` file controls which schemas (identified by path) |
19 | | -should generate XSD documentation. |
| 108 | +# Remove generated documentation |
| 109 | +bundle exec hrma build clean |
| 110 | +
|
| 111 | +# Remove generated documentation and downloaded tools |
| 112 | +bundle exec hrma build distclean |
| 113 | +---- |
20 | 114 |
|
21 | 115 | The resulting documentation per schema will be generated in the path: |
22 | 116 |
|
23 | 117 | * HTML page: `_site/{schema-path}/{xsd-name}/index.html` |
24 | 118 | * Diagrams: `_site/{schema-path}/{xsd-name}/diagrams/*.svg` |
25 | 119 |
|
| 120 | +=== Configuration management |
26 | 121 |
|
27 | | -== Building documentation |
| 122 | +The `config` command manages configuration settings. |
28 | 123 |
|
29 | 124 | [source,sh] |
30 | 125 | ---- |
31 | | -# removes generated artifacts |
32 | | -make clean |
| 126 | +bundle exec hrma config SUBCOMMAND |
| 127 | +---- |
| 128 | + |
| 129 | +Available subcommands: |
| 130 | + |
| 131 | +* `get KEY` - Get a configuration value |
| 132 | +* `set KEY VALUE` - Set a configuration value |
33 | 133 |
|
34 | | -# makes _site |
35 | | -make all |
| 134 | +Supported configuration keys: |
| 135 | + |
| 136 | +* `cache_dir` - Directory for caching downloaded tools (default: `~/.hrma/cache`) |
| 137 | +* `log_dir` - Directory for storing log files (default: `~/.hrma/logs`) |
| 138 | + |
| 139 | +You can set configuration in three ways (in order of precedence): |
| 140 | + |
| 141 | +. Command-line option: `--cache-dir=/path/to/cache` |
| 142 | +. Environment variable: `HRMA_CACHE_DIR=/path/to/cache bundle exec hrma ...` |
| 143 | +. Configuration file: `~/.hrma/config.yml` |
| 144 | + |
| 145 | +Examples: |
| 146 | + |
| 147 | +[source,sh] |
| 148 | +---- |
| 149 | +# Get current cache directory |
| 150 | +bundle exec hrma config get cache_dir |
| 151 | +
|
| 152 | +# Set cache directory |
| 153 | +bundle exec hrma config set cache_dir /path/to/cache |
| 154 | +---- |
| 155 | + |
| 156 | + |
| 157 | +== Advanced features |
| 158 | + |
| 159 | +=== Parallel processing |
| 160 | + |
| 161 | +The tool supports parallel processing using Ruby's Ractor feature through the Fractor framework. This |
| 162 | +significantly speeds up documentation generation for large numbers of schema files. |
| 163 | + |
| 164 | +By default, the tool automatically determines the optimal number of workers to |
| 165 | +use based on your system resources: |
| 166 | + |
| 167 | +* In "auto" mode (default), the number of workers is determined by: |
| 168 | +** Using half of your CPU cores (rounded down) |
| 169 | +** Ensuring at least 2 cores are left free for system processes |
| 170 | +** Using at least 1 worker |
| 171 | +** Using one worker per file when possible (up to the calculated maximum) |
| 172 | + |
| 173 | +This auto-configuration provides a good balance between performance and system |
| 174 | +responsiveness. |
| 175 | + |
| 176 | +[example] |
| 177 | +==== |
| 178 | +* With 4 files on a 4-core system: 1 worker would be used (half cores = 2, but ensuring 2 cores are free = 1) |
| 179 | +* With 4 files on an 8-core system: 4 workers would be used (half cores = 4, which leaves enough free cores) |
| 180 | +* With 4 files on a 16-core system: 4 workers would be used (one per file, even though 8 workers would be available) |
| 181 | +* With 10 files on a 16-core system: 8 workers would be used (half cores = 8, which is less than file count) |
| 182 | +==== |
| 183 | + |
| 184 | +You can manually specify the number of workers: |
| 185 | + |
| 186 | +[source,sh] |
36 | 187 | ---- |
| 188 | +# Use 4 workers for parallel processing |
| 189 | +bundle exec hrma build documentation --workers=4 |
| 190 | +---- |
| 191 | + |
| 192 | +To disable parallel processing entirely: |
| 193 | + |
| 194 | +[source,sh] |
| 195 | +---- |
| 196 | +# Disable parallel processing |
| 197 | +bundle exec hrma build documentation --no-parallel |
| 198 | +---- |
| 199 | + |
| 200 | + |
| 201 | +== Code organization |
| 202 | + |
| 203 | +The `hrma` tool is organized into several components: |
| 204 | + |
| 205 | +=== Command-line interface |
| 206 | + |
| 207 | +* `bin/hrma` - Main executable script |
| 208 | +* `lib/hrma/cli.rb` - Thor-based CLI implementation |
| 209 | +* `lib/hrma/commands/*.rb` - Individual command implementations |
| 210 | + |
| 211 | +=== Build system |
| 212 | + |
| 213 | +* `lib/hrma/build/document_generator.rb` - Main class for generating documentation |
| 214 | +* `lib/hrma/build/schema_processor.rb` - Processes individual schema files |
| 215 | +* `lib/hrma/build/schema_work.rb` - Work item representation for parallel processing |
| 216 | +* `lib/hrma/build/schema_worker.rb` - Worker implementation for parallel processing |
| 217 | +* `lib/hrma/build/tools.rb` - Handles downloading and setting up external tools |
| 218 | +* `lib/hrma/build/cleaner.rb` - Handles cleaning generated files |
| 219 | + |
| 220 | +=== Configuration |
| 221 | + |
| 222 | +* `lib/hrma/config.rb` - Configuration management |
| 223 | +* `lib/hrma/version.rb` - Version information |
| 224 | + |
| 225 | + |
| 226 | +== Copyright and license |
| 227 | + |
| 228 | +Schemas copyright ISO/TC 211. |
| 229 | + |
| 230 | +Other files copyright Ribose Inc. |
0 commit comments