Open manuelfuenmayor opened 2 years ago
Thank you @manuelfuenmayor , I've just run into this!
The problem is that the END_SCHEMA
location affects where the remarks
of the same schema name are located:
one_schema_before.exp
SCHEMA one_schema;
(*"one_schema"
Documentation for Schema 1
*)
END_SCHEMA;
one_schema_after.exp
SCHEMA one_schema;
END_SCHEMA;
(*"one_schema"
Documentation for Schema 1
*)
irb(main):015> Expressir::Express::Parser.from_file('one_schema_before.exp')
=>
#<Expressir::Model::Repository:0x000000010964f550
@schemas=
[#<Expressir::Model::Declarations::Schema:0x0000000109654a78
@children_by_id=nil,
@constants=[],
@entities=[],
@file="one_schema_before.exp",
@functions=[],
@id="one_schema",
@interfaces=[],
@parent=#<Expressir::Model::Repository:0x000000010964f550 ...>,
@procedures=[],
@remark_items=
[#<Expressir::Model::Declarations::RemarkItem:0x000000010964f668
@id="one_schema",
@parent=#<Expressir::Model::Declarations::Schema:0x0000000109654a78 ...>,
@remarks=["Documentation for Schema 1"]>],
@remarks=[],
@rules=[],
@source=nil,
@subtype_constraints=[],
@types=[],
@version=nil>]>
irb(main):016> Expressir::Express::Parser.from_file('one_schema_after.exp')
=>
#<Expressir::Model::Repository:0x0000000104c7be38
@children_by_id=
{"one_schema"=>
#<Expressir::Model::Declarations::Schema:0x0000000104c80438
@constants=[],
@entities=[],
@file="one_schema_after.exp",
@functions=[],
@id="one_schema",
@interfaces=[],
@parent=#<Expressir::Model::Repository:0x0000000104c7be38 ...>,
@procedures=[],
@remark_items=[],
@remarks=["Documentation for Schema 1"],
@rules=[],
@source=nil,
@subtype_constraints=[],
@types=[],
@version=nil>},
@schemas=
[#<Expressir::Model::Declarations::Schema:0x0000000104c80438
@constants=[],
@entities=[],
@file="one_schema_after.exp",
@functions=[],
@id="one_schema",
@interfaces=[],
@parent=#<Expressir::Model::Repository:0x0000000104c7be38 ...>,
@procedures=[],
@remark_items=[],
@remarks=["Documentation for Schema 1"],
@rules=[],
@source=nil,
@subtype_constraints=[],
@types=[],
@version=nil>]>
irb(main):017>
When the remark item of the schema level is outside of the SCHEMA ... END_SCHEMA;
, the remark is accessed with:
(This is the desired behavior)
repo.schemas[0].remarks
When the remark item of the schema level is within the SCHEMA ... END_SCHEMA;
construct, the remark is accessed via:
repo.schemas[0].remark_items["one_schema"].remarks
children_by_id
when a remark item is located within the SCHEMA
blockWhen the remark item of the schema level is outside of the SCHEMA ... END_SCHEMA;
, we can do:
(This is the desired behavior)
# The pattern is `repo.children_by_id[schema_name]`
repo.children_by_id["one_schema"]
When the remark item of the schema level is within the SCHEMA ... END_SCHEMA;
construct, the schema is only found via:
repo.schemas.select { |x| x.id == "one_schema" }
@ronaldtse @manuelfuenmayor
This is by design. I do not know wheather it is wrong or right but the tag works as path from the current scope
Below are the equivalent tag definitions:
one_schema_before.exp
SCHEMA one_schema;
(*""
Documentation for Schema 1
*)
END_SCHEMA;
one_schema_after.exp
SCHEMA one_schema;
END_SCHEMA;
(*"one_schema"
Documentation for Schema 1
*)
In the first case the remark is within "one_schema" scope, so using empty tag attaches the remark to self
In the second case remark is within the scope of "one_schema" parent, so the tag shall be "one_schema"
It works very similar to XPath
In relation to https://github.com/metanorma/iso-10303-detached-docs/issues/82
Taking this EXPRESS syntax as example:
The annotated content enabled by
(*"method_definition_schema"
method is not being recognized by the parser, because it is "inside" the EXPRESS syntax. If I'd move this content afterEND_SCHEMA; -- method_definition_schema
, it would be recognized.This doesn't occur with others methods though.