lutaml 0.11.5 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +28 -5
  3. data/.github/workflows/links.yml +14 -0
  4. data/docs/_config.yml +1 -1
  5. data/docs/_guides/cli-usage.adoc +43 -0
  6. data/docs/_guides/diagram-generation.adoc +3 -3
  7. data/docs/_guides/index.adoc +21 -20
  8. data/docs/_guides/parsing/index.adoc +9 -8
  9. data/docs/_guides/parsing/qea-parsing.adoc +47 -0
  10. data/docs/_guides/repository-management.adoc +44 -0
  11. data/docs/_guides/sysml-modeling.adoc +2 -2
  12. data/docs/_guides/uml-modeling.adoc +1 -1
  13. data/docs/_pages/concepts/diagram-generation.adoc +4 -4
  14. data/docs/_pages/concepts/lur-format.adoc +4 -4
  15. data/docs/_pages/concepts/qea-parsing.adoc +4 -4
  16. data/docs/_pages/concepts/uml-models.adoc +43 -0
  17. data/docs/_pages/core/architecture.adoc +4 -4
  18. data/docs/_pages/core/installation.adoc +7 -7
  19. data/docs/_pages/core/overview.adoc +10 -10
  20. data/docs/_pages/index.adoc +11 -10
  21. data/docs/_references/api/parsers.adoc +61 -0
  22. data/docs/_references/api/presenters.adoc +43 -0
  23. data/docs/_references/api/repository.adoc +67 -0
  24. data/docs/_references/cli/commands.adoc +72 -0
  25. data/docs/_references/configuration/diagram-styles.adoc +3 -3
  26. data/docs/_references/configuration/index.adoc +5 -4
  27. data/docs/_references/configuration/package-metadata.adoc +4 -4
  28. data/docs/_references/formats/index.adoc +5 -4
  29. data/docs/_references/formats/lur-format.adoc +39 -0
  30. data/docs/_references/formats/qea-structure.adoc +4 -4
  31. data/docs/_references/index.adoc +26 -25
  32. data/docs/_tutorials/documentation-site.adoc +47 -0
  33. data/docs/_tutorials/first-lur-package.adoc +45 -0
  34. data/docs/_tutorials/generating-diagrams.adoc +42 -0
  35. data/docs/_tutorials/getting-started.adoc +45 -0
  36. data/docs/_tutorials/index.adoc +28 -37
  37. data/docs/_tutorials/querying-models.adoc +44 -0
  38. data/docs/examples/build_package.rb +12 -0
  39. data/docs/examples/build_site.rb +12 -0
  40. data/docs/examples/city_model.rb +21 -0
  41. data/docs/examples/present_class.rb +10 -0
  42. data/docs/examples/query_model.rb +12 -0
  43. data/docs/examples/render_diagram.rb +11 -0
  44. data/docs/index.adoc +12 -12
  45. data/docs/lychee.toml +24 -57
  46. data/lib/lutaml/version.rb +1 -1
  47. data/lutaml.gemspec +1 -1
  48. data/scripts/check-site-urls.rb +54 -0
  49. data/scripts/check-vendor-link.py +64 -0
  50. metadata +26 -4
@@ -0,0 +1,45 @@
1
+ ---
2
+ permalink: /tutorials/getting-started/
3
+ title: Getting Started with LutaML
4
+ parent: Tutorials
5
+ nav_order: 1
6
+ ---
7
+ = Getting Started with LutaML
8
+
9
+ Create a small UML model and look up a class without an Enterprise Architect file.
10
+ You need Ruby 3.2 or newer and the `lutaml` gem in your bundle.
11
+
12
+ == Install
13
+
14
+ Add `gem "lutaml"` to your Gemfile and run `bundle install`.
15
+ The umbrella gem loads the LML language and UML repository components.
16
+
17
+ == Create the model
18
+
19
+ Save this example as `city_model.rb`:
20
+
21
+ [source,ruby]
22
+ ----
23
+ include::../examples/city_model.rb[]
24
+ ----
25
+
26
+ Run `bundle exec ruby city_model.rb`. It prints `Building`.
27
+ The explicit IDs identify elements within the model; the repository assigns the
28
+ qualified path `ModelRoot::City::Building` from their package hierarchy.
29
+
30
+ == Explore the repository
31
+
32
+ In another script, load `city_model.rb` and call `CityModel.repository`.
33
+ Use `classes_in_package("ModelRoot::City")` to list its classes, or
34
+ `statistics` to obtain model counts. An empty model still has the synthetic
35
+ `ModelRoot` package, so the example's package count is two.
36
+
37
+ UML documents and LML documents are different types. For textual LML input use
38
+ `Lutaml::Lml.parse_document`, rather than passing an LML document directly to
39
+ the UML repository. See link:{site-baseurl}/references/api/parsers/[Parser APIs].
40
+
41
+ == Next steps
42
+
43
+ * link:{site-baseurl}/tutorials/first-lur-package/[Save and reload a LUR package].
44
+ * link:{site-baseurl}/tutorials/querying-models/[Query the model].
45
+ * link:{site-baseurl}/concepts/uml-models/[Understand the UML model structure].
@@ -1,4 +1,5 @@
1
1
  ---
2
+ permalink: /tutorials/
2
3
  title: Tutorials
3
4
  nav_order: 2
4
5
  has_children: true
@@ -9,88 +10,78 @@ has_children: true
9
10
 
10
11
  This section provides step-by-step learning paths to help you accomplish specific tasks with LutaML. Each tutorial walks you through a complete workflow from start to finish.
11
12
 
12
- == Available Tutorials
13
+ == Tutorials
13
14
 
14
- === link:/tutorials/getting-started[Getting Started with LutaML]
15
+ === link:{site-baseurl}/tutorials/getting-started/[Getting Started with LutaML]
15
16
 
16
- Your first steps with LutaML. Learn how to install, parse your first model file, and explore basic functionality.
17
+ Create a small typed UML model and verify an indexed class lookup.
17
18
 
18
19
  **What you'll learn:**
19
20
 
20
21
  * Installing LutaML
21
- * Parsing XMI and QEA files
22
- * Understanding the `Lutaml::Parser` interface
22
+ * Creating a UML document
23
+ * Understanding parser and repository boundaries
23
24
  * Basic model exploration
24
25
 
25
- **Time:** 15 minutes
26
-
27
26
  ---
28
27
 
29
- === link:/tutorials/first-lur-package[Building Your First LUR Package]
28
+ === link:{site-baseurl}/tutorials/first-lur-package/[Building Your First LUR Package]
30
29
 
31
- Create a LutaML UML Repository (LUR) package from an XMI or QEA file for fast loading and querying.
30
+ Export a typed UML repository to a LUR package and verify a reload.
32
31
 
33
32
  **What you'll learn:**
34
33
 
35
- * Converting XMI/QEA to LUR format
34
+ * Exporting a UML repository
36
35
  * Understanding LUR package structure
37
36
  * Loading and querying LUR packages
38
- * Performance benefits
39
-
40
- **Time:** 20 minutes
37
+ * Preserving source and dependency versions
41
38
 
42
39
  ---
43
40
 
44
- === link:/tutorials/generating-diagrams[Generating Diagrams]
41
+ === link:{site-baseurl}/tutorials/generating-diagrams/[Generating Diagrams]
45
42
 
46
- Generate pixel-perfect SVG diagrams from Enterprise Architect models with full styling support.
43
+ Render a textual LML model with Graphviz and verify the resulting SVG.
47
44
 
48
45
  **What you'll learn:**
49
46
 
50
- * Loading diagrams from QEA files
51
- * Basic diagram generation
52
- * Customizing colors and styles
47
+ * Parsing textual LML
48
+ * Selecting the output format
49
+ * Checking the Graphviz prerequisite
53
50
  * Exporting diagrams
54
51
 
55
- **Time:** 25 minutes
56
-
57
52
  ---
58
53
 
59
- === link:/tutorials/documentation-site[Creating a Documentation Site]
54
+ === link:{site-baseurl}/tutorials/documentation-site/[Creating a Documentation Site]
60
55
 
61
- Build a complete SPA documentation website from your UML model with search and navigation.
56
+ Generate an HTML model browser, inspect it locally, and understand output modes.
62
57
 
63
58
  **What you'll learn:**
64
59
 
65
- * Using the `build-spa` command
60
+ * Using the Ruby static-site API
66
61
  * Understanding output modes
67
62
  * Customizing the site
68
- * Deploying documentation
69
-
70
- **Time:** 20 minutes
63
+ * Serving and publishing generated output
71
64
 
72
65
  ---
73
66
 
74
- === link:/tutorials/querying-models[Searching and Querying Models]
67
+ === link:{site-baseurl}/tutorials/querying-models/[Searching and Querying Models]
75
68
 
76
- Master the query DSL and search capabilities to find exactly what you need in large models.
69
+ Compare exact lookups, structured queries, and grouped text-search results.
77
70
 
78
71
  **What you'll learn:**
79
72
 
80
73
  * Full-text search
81
74
  * Using the query DSL
82
- * Filtering by stereotype
83
- * Advanced queries
84
-
85
- **Time:** 30 minutes
75
+ * Filtering objects by name
76
+ * Applying queries to a saved package
86
77
 
87
78
  == Prerequisites
88
79
 
89
80
  Most tutorials assume you have:
90
81
 
91
- * Ruby 2.7+ installed
82
+ * Ruby 3.2+ installed
92
83
  * Basic command-line knowledge
93
- * LutaML installed (see link:/installation[Installation Guide])
84
+ * LutaML installed (see link:{site-baseurl}/core/installation/[Installation Guide])
94
85
 
95
86
  == Tutorial Format
96
87
 
@@ -104,6 +95,6 @@ Each tutorial follows this structure:
104
95
 
105
96
  == Related Sections
106
97
 
107
- * link:/pages[Core Topics] - Fundamental concepts
108
- * link:/guides[Guides] - Task-oriented how-to documentation
109
- * link:/references[Reference] - Detailed specifications
98
+ * link:{site-baseurl}/core/[Core Topics] - Fundamental concepts
99
+ * link:{site-baseurl}/guides/[Guides] - Task-oriented how-to documentation
100
+ * link:{site-baseurl}/references/[Reference] - Detailed specifications
@@ -0,0 +1,44 @@
1
+ ---
2
+ permalink: /tutorials/querying-models/
3
+ title: Searching and Querying Models
4
+ parent: Tutorials
5
+ nav_order: 5
6
+ ---
7
+ = Searching and Querying Models
8
+
9
+ Use the model from link:{site-baseurl}/tutorials/getting-started/[Getting Started]
10
+ to compare an exact lookup, a structured query, and a text search.
11
+
12
+ == Run the query
13
+
14
+ Save this as `query_model.rb` beside `city_model.rb`:
15
+
16
+ [source,ruby]
17
+ ----
18
+ include::../examples/query_model.rb[]
19
+ ----
20
+
21
+ Run `bundle exec ruby query_model.rb`. It prints `Building`, followed by `1`.
22
+ The assertion checks that the query returned the expected class.
23
+
24
+ == Choose a lookup method
25
+
26
+ * `find_class("ModelRoot::City::Building")` resolves a qualified name.
27
+ It returns `nil` when no class matches, unless `raise_on_error: true` is set.
28
+ * `classes_in_package("ModelRoot::City", recursive: true)` includes child packages.
29
+ Use this method for package filtering with `lutaml-uml` 1.0.3; the query DSL's
30
+ `in_package` condition currently raises a `NameError` for `PackagePath`.
31
+ * `query { |q| q.classes.where(name: /Building/) }.all` filters objects and
32
+ returns model instances. Chain `order_by(:name)` or `limit(10)` before `.all`.
33
+ * `search("Building", types: [:class])` returns a hash with result groups and
34
+ `:total`; it does not return the same array as a structured query.
35
+
36
+ Package paths start at `ModelRoot`, even when the document has a different name.
37
+ Use `package_tree` to inspect the hierarchy instead of guessing paths from filenames.
38
+
39
+ == Query a saved model
40
+
41
+ Replace `CityModel.repository` with
42
+ `Lutaml::UmlRepository::Repository.from_package("city.lur")` after completing
43
+ the link:{site-baseurl}/tutorials/first-lur-package/[LUR package tutorial].
44
+ The query methods work on the loaded repository in the same way.
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "city_model"
4
+ # lutaml-uml 1.0.3's exporter uses this component's version constant.
5
+ require "lutaml/uml/version"
6
+
7
+ path = ARGV.fetch(0, "city.lur")
8
+ CityModel.repository.export_to_package(path)
9
+ repository = Lutaml::UmlRepository::Repository.from_package(path)
10
+ raise "Class was not preserved" unless repository.find_class("ModelRoot::City::Building")
11
+
12
+ puts repository.find_class("ModelRoot::City::Building").name
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "city_model"
4
+ require "lutaml/uml/version"
5
+
6
+ path = ARGV.fetch(0, "browser.html")
7
+ Lutaml::UmlRepository::StaticSite.generate(
8
+ CityModel.repository, mode: :single_file, output: path
9
+ )
10
+ raise "Site was not generated" unless File.size?(path)
11
+
12
+ puts path
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml"
4
+
5
+ module CityModel
6
+ def self.repository
7
+ building = Lutaml::Uml::UmlClass.new(
8
+ name: "Building", xmi_id: "building-1", stereotype: ["featureType"]
9
+ )
10
+ city = Lutaml::Uml::Package.new(
11
+ name: "City", xmi_id: "city-1", classes: [building]
12
+ )
13
+ document = Lutaml::Uml::Document.new(name: "City model", packages: [city])
14
+ Lutaml::UmlRepository::Repository.from_document(document)
15
+ end
16
+ end
17
+
18
+ if $PROGRAM_NAME == __FILE__
19
+ repository = CityModel.repository
20
+ puts repository.find_class("ModelRoot::City::Building").name
21
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "city_model"
4
+ require "lutaml/uml_repository/presenters/class_presenter"
5
+
6
+ repository = CityModel.repository
7
+ element = repository.find_class("ModelRoot::City::Building")
8
+ presenter = Lutaml::UmlRepository::Presenters::PresenterFactory.create(element, repository)
9
+ puts presenter.to_text
10
+ raise "Presenter lost the name" unless presenter.to_hash[:name] == "Building"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "city_model"
4
+
5
+ repository = CityModel.repository
6
+ classes = repository.query do |query|
7
+ query.classes.where(name: "Building")
8
+ end.all
9
+ raise "Unexpected query result" unless classes.map(&:name) == ["Building"]
10
+
11
+ puts classes.map(&:name)
12
+ puts repository.search("Building", types: [:class])[:total]
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml"
4
+
5
+ document = Lutaml::Lml.parse("diagram City { class Building {} }")
6
+ formatter = Lutaml::Formatter::Graphviz.new
7
+ formatter.type = :svg
8
+ svg = formatter.format(document)
9
+ raise "Graphviz did not return SVG" unless svg.include?("<svg")
10
+
11
+ File.write(ARGV.fetch(0, "city.svg"), svg)
data/docs/index.adoc CHANGED
@@ -25,25 +25,25 @@ LutaML provides a unified interface for:
25
25
 
26
26
  New to LutaML? Start here:
27
27
 
28
- * link:/installation[Installation Guide] - Get LutaML up and running
29
- * link:/tutorials/getting-started[Quick Start Tutorial] - Your first steps with LutaML
30
- * link:/overview[What is LutaML?] - Learn about the architecture and capabilities
28
+ * link:{site-baseurl}/core/installation/[Installation Guide] - Get LutaML up and running
29
+ * link:{site-baseurl}/tutorials/getting-started/[Quick Start Tutorial] - Your first steps with LutaML
30
+ * link:{site-baseurl}/core/overview/[What is LutaML?] - Learn about the architecture and capabilities
31
31
 
32
32
  === Documentation Sections
33
33
 
34
- ==== link:/core[Core Topics]
34
+ ==== link:{site-baseurl}/core/[Core Topics]
35
35
 
36
36
  Fundamental concepts and essential information about LutaML's architecture, components, and capabilities.
37
37
 
38
- ==== link:/tutorials[Tutorials]
38
+ ==== link:{site-baseurl}/tutorials/[Tutorials]
39
39
 
40
40
  Step-by-step learning paths to help you accomplish specific tasks with LutaML.
41
41
 
42
- ==== link:/guides[Guides]
42
+ ==== link:{site-baseurl}/guides/[Guides]
43
43
 
44
44
  Task-oriented how-to documentation for common workflows and operations.
45
45
 
46
- ==== link:/references[Reference]
46
+ ==== link:{site-baseurl}/references/[Reference]
47
47
 
48
48
  Detailed technical specifications, API documentation, and configuration schemas.
49
49
 
@@ -51,14 +51,14 @@ Detailed technical specifications, API documentation, and configuration schemas.
51
51
 
52
52
  * https://github.com/lutaml/lutaml[GitHub Repository]
53
53
  * https://rubygems.org/gems/lutaml[RubyGems Package]
54
- * link:/installation[Installation]
55
- * link:/references/cli/commands[CLI Reference]
56
- * link:/references/api/repository[API Reference]
54
+ * link:{site-baseurl}/core/installation/[Installation]
55
+ * link:{site-baseurl}/references/cli/commands/[CLI Reference]
56
+ * link:{site-baseurl}/references/api/repository/[API Reference]
57
57
 
58
58
  === Community
59
59
 
60
60
  LutaML is open source and maintained by https://www.ribose.com[Ribose].
61
61
 
62
62
  * Report issues: https://github.com/lutaml/lutaml/issues
63
- * Contribute: https://github.com/lutaml/lutaml/blob/main/CONTRIBUTING.md
64
- * License: https://github.com/lutaml/lutaml/blob/main/LICENSE[BSD-3-Clause]
63
+ * Contribute: https://github.com/lutaml/lutaml/pulls
64
+ * License: https://opensource.org/licenses/MIT[MIT]
data/docs/lychee.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  # Lychee link checker configuration for LutaML documentation
2
2
 
3
- # Cache results for 1 day to speed up repeated checks
3
+ # Cache results to speed up repeated checks
4
4
  cache = true
5
5
 
6
6
  # Maximum number of concurrent requests
@@ -12,72 +12,39 @@ timeout = 30
12
12
  # Maximum number of retries per link
13
13
  max_retries = 3
14
14
 
15
- # Follow redirects
16
- follow_redirects = true
17
-
18
- # Maximum redirect depth
15
+ # Maximum redirect depth (redirects are followed up to this many)
19
16
  max_redirects = 5
20
17
 
21
- # Accept status codes
22
- accept = [
23
- 200, # OK
24
- 203, # Non-Authoritative Information
25
- 204, # No Content
26
- 206, # Partial Content
27
- 429, # Too Many Requests (we'll retry)
28
- ]
18
+ # Accept these HTTP status codes as success
19
+ accept = [200, 203, 204, 206, 429]
29
20
 
30
- # Exclude patterns (glob format)
21
+ # Exclude URLs matching these regexes
31
22
  exclude = [
32
- # Exclude localhost links
33
- 'http://localhost*',
34
- 'http://127.0.0.1*',
35
-
36
- # Exclude example domains
37
- 'http://example.com*',
38
- 'https://example.com*',
39
-
40
- # Exclude GitHub edit links (they may 404 for non-contributors)
41
- 'https://github.com/*/edit/*',
42
-
43
- # Exclude potential rate-limited APIs
44
- 'https://api.github.com/*',
45
- ]
46
-
47
- # Include patterns - check these file types
48
- include = [
49
- '**/*.html',
50
- '**/*.md',
51
- '**/*.adoc',
23
+ # This exact URL is probed separately; only an explicit challenge is deferred.
24
+ '^https://sparxsystems\.com/$',
25
+ # Checked against built files by scripts/check-site-urls.rb before lychee.
26
+ '^https://www\.lutaml\.org/lutaml(?:/|$)',
27
+ '^https://lutaml\.github\.io/lutaml(?:/|$)',
28
+ '^https?://localhost(?:[:/]|$)',
29
+ '^https?://127\.0\.0\.1(?:[:/]|$)',
30
+ '^https?://example\.com(?:[:/]|$)',
31
+ '^https://github\.com/[^/]+/[^/]+/edit/',
32
+ '^https://api\.github\.com/',
52
33
  ]
53
34
 
54
- # HTTP headers to send with requests
55
- [headers]
56
- # Set user agent
57
- User-Agent = "Mozilla/5.0 (compatible; Lychee/0.13.0; +https://github.com/lycheeverse/lychee)"
58
-
59
- # GitHub API token (if available in environment)
60
- # Authorization = "Bearer ${GITHUB_TOKEN}"
61
-
62
- # Verbose output
63
- verbose = true
64
-
65
- # Don't show progress bar in CI
35
+ # Do not show a progress bar in CI
66
36
  no_progress = true
67
37
 
68
38
  # Output format
69
39
  format = "markdown"
70
40
 
71
- # Exclude paths from file system checks
72
- exclude_path = [
73
- ".git/",
74
- "_site/",
75
- "node_modules/",
76
- "vendor/",
77
- ]
41
+ # HTTP headers to send with requests
42
+ header = { "User-Agent" = "Mozilla/5.0 (compatible; Lychee/0.23.0; +https://github.com/lycheeverse/lychee)" }
78
43
 
79
- # Scheme to use when checking local files
80
- scheme = "https"
44
+ # Schemes to check
45
+ scheme = ["https", "http"]
81
46
 
82
- # Base URL for relative links
83
- # base = "https://lutaml.github.io/lutaml"
47
+ # Exclude these paths from file-system discovery. NOTE: do not exclude _site/
48
+ # here — the CI link check explicitly targets _site/**/*.html, and excluding it
49
+ # would drop every file ("No files found") and fail with failIfEmpty.
50
+ exclude_path = [".git/", "node_modules/", "vendor/"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lutaml
4
- VERSION = "0.11.5"
4
+ VERSION = "0.11.7"
5
5
  end
data/lutaml.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  # (fiddle was removed from Ruby 4.0 default gems, breaking reline on Windows)
35
35
  spec.add_dependency "fiddle"
36
36
  spec.add_dependency "lutaml-lml"
37
- spec.add_dependency "lutaml-model", "~> 0.8.114"
37
+ spec.add_dependency "lutaml-model", "~> 0.8.159"
38
38
  spec.add_dependency "lutaml-uml", "~> 1.0"
39
39
  spec.metadata["rubygems_mfa_required"] = "true"
40
40
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cgi"
4
+ require "pathname"
5
+ require "set"
6
+ require "uri"
7
+ require "yaml"
8
+
9
+ config = YAML.safe_load(File.read(ARGV.fetch(0)))
10
+ site = Pathname.new(ARGV.fetch(1)).realpath
11
+ origin = URI(config.fetch("url"))
12
+ base = config.fetch("baseurl", "").sub(%r{/$}, "")
13
+ hosts = [origin.host, "lutaml.github.io"]
14
+ checked = Set.new
15
+ errors = []
16
+
17
+ site.glob("**/*.html").each do |file|
18
+ File.read(file).scan(/\b(?:href|src)=["']([^"']+)["']/).flatten.each do |value|
19
+ uri = URI(CGI.unescapeHTML(value))
20
+ own_url = %w[http https].include?(uri.scheme) && hosts.include?(uri.host)
21
+ local_url = uri.scheme.nil? && uri.host.nil?
22
+ next unless own_url || local_url
23
+
24
+ if local_url && uri.path.start_with?("/") && !base.empty? &&
25
+ uri.path != base && !uri.path.start_with?("#{base}/")
26
+ errors << "#{file.relative_path_from(site)}: #{value} is outside baseurl #{base}"
27
+ next
28
+ end
29
+
30
+ if own_url || uri.path.start_with?("/")
31
+ next if own_url && uri.path != base && !uri.path.start_with?("#{base}/")
32
+ path = URI::DEFAULT_PARSER.unescape(uri.path.delete_prefix(base)).sub(%r{^/}, "")
33
+ target = site.join(path).cleanpath
34
+ else
35
+ target = uri.path.empty? ? file : file.dirname.join(URI::DEFAULT_PARSER.unescape(uri.path)).cleanpath
36
+ end
37
+ target = target.join("index.html") if target.directory?
38
+ key = "#{target}##{uri.fragment}"
39
+ next unless checked.add?(key)
40
+
41
+ if !target.to_s.start_with?("#{site}/") || !target.file? || !target.realpath.to_s.start_with?("#{site}/")
42
+ errors << "#{file.relative_path_from(site)}: #{value} has no built target"
43
+ elsif uri.fragment && !uri.fragment.empty?
44
+ anchors = File.read(target).scan(/\b(?:id|name)=["']([^"']+)["']/).flatten
45
+ fragment = URI::DEFAULT_PARSER.unescape(uri.fragment)
46
+ errors << "#{file.relative_path_from(site)}: #{value} has no built anchor" unless anchors.include?(fragment)
47
+ end
48
+ rescue URI::InvalidURIError
49
+ errors << "#{file.relative_path_from(site)}: invalid URL #{value}"
50
+ end
51
+ end
52
+ abort "No site URLs found in #{site}" if checked.empty?
53
+ abort errors.join("\n") unless errors.empty?
54
+ puts "Verified #{checked.size} built local/canonical targets and anchors"
@@ -0,0 +1,64 @@
1
+ """Probe the exact vendor homepage without treating arbitrary 403s as success."""
2
+ import sys
3
+ import urllib.error
4
+ import urllib.request
5
+
6
+ VENDOR_URL = "https://sparxsystems.com/"
7
+
8
+
9
+ def classify(url, status, headers):
10
+ if url != VENDOR_URL:
11
+ raise ValueError("Unexpected vendor URL or redirect target")
12
+ if 200 <= status < 300:
13
+ return "reachable"
14
+ normalized = {key.lower(): value.strip().lower() for key, value in headers.items()}
15
+ if status == 403 and normalized.get("cf-mitigated") == "challenge":
16
+ return "automated access blocked; availability unverified"
17
+ raise ValueError(f"Vendor link returned unaccepted HTTP {status}")
18
+
19
+
20
+ class NoRedirect(urllib.request.HTTPRedirectHandler):
21
+ def redirect_request(self, request, fp, code, message, headers, new_url):
22
+ return None
23
+
24
+
25
+ def self_test():
26
+ assert classify(VENDOR_URL, 200, {}) == "reachable"
27
+ assert "unverified" in classify(VENDOR_URL, 403, {"CF-Mitigated": "challenge"})
28
+ for url, status, headers in [
29
+ (VENDOR_URL, 403, {}),
30
+ (VENDOR_URL, 403, {"cf-mitigated": "other"}),
31
+ (VENDOR_URL, 404, {"cf-mitigated": "challenge"}),
32
+ ("https://unrelated.example/", 403, {"cf-mitigated": "challenge"}),
33
+ ("https://sparxsystems.com/missing", 200, {}),
34
+ (VENDOR_URL, 302, {}),
35
+ ]:
36
+ try:
37
+ classify(url, status, headers)
38
+ except ValueError:
39
+ continue
40
+ raise AssertionError((url, status, headers))
41
+ print("Vendor policy controls passed: 2 positive, 6 negative")
42
+
43
+
44
+ def probe():
45
+ opener = urllib.request.build_opener(NoRedirect())
46
+ request = urllib.request.Request(VENDOR_URL, headers={"User-Agent": "Lutaml-docs-link-check"})
47
+ try:
48
+ response = opener.open(request, timeout=30)
49
+ except urllib.error.HTTPError as response:
50
+ result = classify(response.geturl(), response.code, response.headers)
51
+ else:
52
+ with response:
53
+ result = classify(response.geturl(), response.status, response.headers)
54
+ if "unverified" in result:
55
+ print(f"::notice title=Vendor link availability::{VENDOR_URL}: {result}")
56
+ else:
57
+ print(f"Verified vendor homepage: {VENDOR_URL}")
58
+
59
+
60
+ if __name__ == "__main__":
61
+ try:
62
+ self_test() if sys.argv[1:] == ["--self-test"] else probe()
63
+ except (ValueError, OSError, urllib.error.URLError) as error:
64
+ sys.exit(str(error))