Skip to content

需求图

🌐 Requirement Diagram

需求图提供了对需求及其相互连接关系以及与其他文档元素关系的可视化。建模规范遵循 SysML v1.6 定义的标准。

渲染需求很简单。

🌐 Rendering requirements is straightforward.

语法

🌐 Syntax

需求图有三种类型的组件:需求、元素和关系。

🌐 There are three types of components to a requirement diagram: requirement, element, and relationship.

定义每个的语法如下所示。用尖括号表示的单词,如 <word>,是枚举关键字,其选项在表格中详细说明。user_defined_... 用于任何需要用户输入的地方。

🌐 The grammar for defining each is defined below. Words denoted in angle brackets, such as <word>, are enumerated keywords that have options elaborated in a table. user_defined_... is use in any place where user input is expected.

关于用户文本的重要说明:所有输入都可以加引号,也可以不加引号。例如,id: "here is an example"id: here is an example 都是有效的。然而,用户在使用未加引号的输入时必须小心。如果检测到其他关键字,解析器将会失败。

🌐 An important note on user text: all input can be surrounded in quotes or not. For example, both id: "here is an example" and id: here is an example are both valid. However, users must be careful with unquoted input. The parser will fail if another keyword is detected.

要求

🌐 Requirement

需求定义包含需求类型、名称、ID、文本、风险和验证方法。语法如下:

🌐 A requirement definition contains a requirement type, name, id, text, risk, and verification method. The syntax follows:

<type> user_defined_name {
    id: user_defined_id
    text: user_defined text
    risk: <risk>
    verifymethod: <method>
}

类型、风险和方法是 SysML 中定义的枚举。

🌐 Type, risk, and method are enumerations defined in SysML.

关键字选项
类型需求, 功能需求, 接口需求, 性能需求, 物理需求, 设计约束
风险低, 中, 高
验证方法分析, 检查, 测试, 演示

元素

🌐 Element

元素定义包含元素名称、类型和文档引用。这三者都是用户定义的。元素功能旨在保持轻量,同时允许将需求与其他文档的部分内容关联起来。

🌐 An element definition contains an element name, type, and document reference. These three are all user defined. The element feature is intended to be lightweight but allow requirements to be connected to portions of other documents.

element user_defined_name {
    type: user_defined_type
    docref: user_defined_ref
}

Markdown 格式

🌐 Markdown Formatting

在允许用户自定义文本的地方(如名称、需求文本、元素文档引用等),你可以:

🌐 In places where user defined text is possible (like names, requirement text, element docref, etc.), you can:

  • 将文本用引号括起来:“example text”
  • 在引号内使用 markdown 格式:"**加粗文本** 和 *斜体*"

示例:

🌐 Example:

关系

🌐 Relationship

关系由源节点、目标节点和关系类型组成。

🌐 Relationships are comprised of a source node, destination node, and relationship type.

每个都遵循……的定义格式

🌐 Each follows the definition format of

{name of source} - <type> -> {name of destination}

或者

🌐 or

{name of destination} <- <type> - {name of source}

“来源名称”和“目标名称”应为在其他地方定义的需求或元素节点的名称。

关系类型可以是包含、复制、派生、满足、验证、细化或追踪之一。

🌐 A relationship type can be one of contains, copies, derives, satisfies, verifies, refines, or traces.

图表中标注了每种关系。

🌐 Each relationship is labeled in the diagram.

更大示例

🌐 Larger Example

此示例使用了该图表的所有功能。

🌐 This example uses all features of the diagram.

方向

🌐 Direction

可以使用 direction 语句以不同方向呈现图表。有效值为:

🌐 The diagram can be rendered in different directions using the direction statement. Valid values are:

  • TB - 从上到下(默认)
  • BT - 从底部到顶部
  • LR - 从左到右
  • RL - 从右到左

示例:

🌐 Example:

样式

🌐 Styling

需求和元素可以使用直接样式或类来设置样式。一般来说,在应用样式或类时,它接受一个需求或元素名称的列表以及一个类名列表,从而允许一次分配多个类(唯一的例外是简写语法 :::,它可以分配多个类,但一次只能分配给一个需求或元素)。

🌐 Requirements and elements can be styled using direct styling or classes. As a rule of thumb, when applying styles or classes, it accepts a list of requirement or element names and a list of class names allowing multiple assignments at a time (The only exception is the shorthand syntax ::: which can assign multiple classes but only to one requirement or element at a time).

直接样式

🌐 Direct Styling

使用 style 关键字直接应用 CSS 样式:

🌐 Use the style keyword to apply CSS styles directly:

类定义

🌐 Class Definitions

使用 classDef 定义可重用样式:

🌐 Define reusable styles using classDef:

默认类

🌐 Default class

如果一个类被命名为 default,它将应用于所有节点。特定的样式和类应该在此之后定义,以覆盖已应用的默认样式。

🌐 If a class is named default it will be applied to all nodes. Specific styles and classes should be defined afterwards to override the applied default styling.

classDef default fill:#f9f,stroke:#333,stroke-width:4px;

应用类

🌐 Applying Classes

课程可以通过两种方式进行应用:

🌐 Classes can be applied in two ways:

  1. 使用 class 关键字:
class test_req,test_entity important
  1. 在定义过程中或之后使用 ::: 简写语法:
requirement test_req:::important {
    id: 1
    text: class styling example
    risk: low
    verifymethod: test
}
element test_elem {
}

test_elem:::myClass

综合示例

🌐 Combined Example

Opens in MermaidChart.com