MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    在 mirai-console 插件配置文件中添加注释

    技术交流板块
    mirai-console 插件 注释 教程 配置文件
    2
    2
    126
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MrXiaoM
      MrXiaoM 童心未泯 last edited by MrXiaoM

      有时候我们可能不可避免地要给配置文件添加注释以便提升配置文件可读性,这个时候就要添加注释了。

      怎么用

      要添加注释,首先导入包 yamlkt

      compileOnly("net.mamoe.yamlkt:yamlkt-jvm:0.10.2")
      

      然后在你的配置上头打上 @Comment 注解就行,比如

      public object MyConfig : AutoSavePluginConfig("config") {
          @Comment("这是一条注释")
          public var message: String by value("awa")
      
          @Comment(
          """
          可以多行
          就像这样
          或者你用换行符也行
          """
          )
          public var enable : Boolean by value(true)
      }
      

      这其实 又是一个坑

      我想加注释无奈 mirai-console 文档里没教程。

      某天我忽然想到自带的自动登录配置文件不是有注释吗,于是我在源码找到了 AutoLoginConfig,才看到了 @Comment 注解。

      其实这个东西就在 Him188/yamlkt 的最下面

      1 Reply Last reply Reply Quote 0
      • cssxsh
        cssxsh last edited by cssxsh

        不是自带 @ValueDescription 吗
        如果你想在 复杂的 data 内部进行注释 才需要 @Comment

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact