Skip to content

Commit b4fd1d3

Browse files
committed
docs: update datagen entry layout guidance
1 parent c9c97ae commit b4fd1d3

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • versioned_docs/version-26.1.2/getting-started/step-by-step-with-datagen

versioned_docs/version-26.1.2/getting-started/step-by-step-with-datagen/step3.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ book
4444
- `DemoBook.java` is the main entry point for the book. It is a subclass of the type SingleBookSubProvider which sets up the book and links its categories.
4545
- Categories are set up in `generateCategories()`. Just call `this.add(new <...>)` as shown in the existing file to link a category to the book.
4646
- `FeaturesCategory.java`, `FormattingCategory.java`, `IndexModeCategory.java` are category providers. They work the same way as the DemoBook.java, except that they set up data for categories, and allow to add entries.
47-
- Entries are added in generateEntries(). Just call `this.add(new <...>)` as shown in the existing file to link an entry to the category.
47+
- Entries are added in `generateEntries()`. Just call `this.add(new <...>)` as shown in the existing file to link an entry to the category.
48+
- Entry placement in node view is now usually handled with `this.layout()`.
49+
- For simple category-wide layouts, use `configureLayout(...)` and place entries by id, for example `layout.entry(MyEntry.ID).at(0, 0)` or `layout.entry(MyOtherEntry.ID).rightOf(MyEntry.ID, 4).below(1)`.
50+
- If you prefer to place entries inline while generating them, keep the generated `BookEntryModel` and use `this.layout().entry(entryModel)...`.
51+
- `FeaturesCategory.java` still contains a `generateEntryMap()` example, but only as a legacy reference.
4852
- `CommandEntry.java`, `ImageEntry.java`, `BasicFormattingEntry.java` (and all the other java files in the category subdirectories) are entry providers. They work the same way as the category providers, except that they set up data for entries, and allow to add pages.
4953
- Pages are added in `generatePages()`.
5054
- Pages are a bit more complicated than simply calling `this.add()`, it is best to take a look at some of the entries to understand how they work. Very simply put, you always need a page definition that you can set with `this.page(...)`, followed by the texts you want to display on that page.
@@ -53,8 +57,10 @@ book
5357

5458
1. Start by copying and renaming the FormattingCategory into e.g. "MyTestCategory.java" and adding a directory/package "mytestcategory".
5559
2. Add a new entry (e.g. copy the "BasicFormattingEntry.java" to "/mytestcategory/MyTestEntry.java") with a few pages into that new directory.
56-
3. Remove the references in your MyTestCategory to the entries of FormattingCategory and instead place `this.add(new MyTestEntry().generate('l'))`.
57-
4. Modify the placement of the entry in the 2D string array in generateEntryMap() to place your entry where you would like it to be in the node view.
60+
3. Remove the references in your MyTestCategory to the entries of FormattingCategory and instead place `this.add(new MyTestEntry(this).generate())`.
61+
4. Place the entry in node view with one of the layout helpers:
62+
- In `configureLayout(...)`, for example `layout.entry(MyTestEntry.ID).at(0, 0)`.
63+
- Or inline in `generateEntries()`, for example `var myEntry = this.add(new MyTestEntry(this).generate()); this.layout().entry(myEntry).at(0, 0);`.
5864

5965
## Test your changes
6066

@@ -77,4 +83,4 @@ You now have a working and already modified book that you can extend to your lik
7783
- Remove demo content.
7884

7985
For an overview of the possible page types and other content settings, you can view once again the demo book content, or take a look at the [Basics](/docs/basics) and [Advanced](/docs/advanced) documentation. The documentation documents the JSON format, however if you compare it to the demo book you will notice corresponding java methods, usually prefixed with "with".
80-
Another good resource is: https://github.com/klikli-dev/theurgy/tree/version/1.21.1/src/main/java/com/klikli_dev/theurgy/datagen/book as theurgy extensively uses Modonomicon for its in-game documentation.
86+
Another good resource is: https://github.com/klikli-dev/theurgy/tree/version/1.21.1/src/main/java/com/klikli_dev/theurgy/datagen/book as theurgy extensively uses Modonomicon for its in-game documentation.

0 commit comments

Comments
 (0)