From 0c9b36362c97dcf43483144fd60ed666369a3740 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 13 May 2024 22:14:06 -0700 Subject: [PATCH] feat(minecraft): add initial docs for ComponentParser (#33) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Is this sufficient? Should I talk about the annotations this also uses? ---- 📚 Documentation preview 📚: https://incendocloud--33.org.readthedocs.build/en/33/ --- .gitignore | 2 +- docs/minecraft/minecraft-extras.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1b44fdb..9a2bc80 100644 --- a/.gitignore +++ b/.gitignore @@ -316,7 +316,7 @@ ipython_config.py # pyenv # For a library or package, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: -# .python-version +.python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/docs/minecraft/minecraft-extras.md b/docs/minecraft/minecraft-extras.md index c72254d..702e431 100644 --- a/docs/minecraft/minecraft-extras.md +++ b/docs/minecraft/minecraft-extras.md @@ -16,6 +16,7 @@ - [MinecraftExceptionHandler](#minecraft-exception-handler) - [RichDescription](#rich-description) - [TextColorParser](#text-color-parser) +- [ComponentParser](#component-parser) @@ -148,3 +149,17 @@ It parses `NamedTextColor`, legacy color codes using `&` as well as hex codes. ```java ParserDescriptor parser = TextColorParser.textColorParser(); ``` + +## Component Parser + +`ComponentParser` is a [parser](../core/index.md#parsers) which parses Adventure `Component`s via +a specified "decoder" function. + +```java +// This creates a parser that uses MiniMessage for decoding the argument, and uses +// greedy string parsing. +ParserDescriptor parser = ComponentParser.componentParser( + MiniMessage.miniMessage(), + StringParser.StringMode.GREEDY_FLAG_YIELDING +); +```