Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Mods & source code linking system #68

Open
anonymous123-code opened this issue Dec 2, 2023 · 1 comment
Open

Example Mods & source code linking system #68

anonymous123-code opened this issue Dec 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@anonymous123-code
Copy link
Contributor

anonymous123-code commented Dec 2, 2023

What would you like the wiki to cover?

Add a Remark Plugin that enables linking code blocks to real code files. Code blocks should include which example mod is to be linked, the relative path to example mod code, and (optionally) a label of the span which is included. In the source files, comments should specify the specific ranges for each labels. Leading whitespace that all lines of an embed have in common should be trimmed.
https://github.com/kevin940726/remark-code-import might work as a baseline, but the span is defined in the code block, not in the source code, which is not ideal.

Why should this be added to the wiki?

Currently one of the main issues with the wiki is that it is difficult to see to which file a code block actually belongs. This would fix the issue (See #67 ). Additionally, it would enable us to write example mods without the danger of source code and markdown getting out of sync.

Example

For example, for this code block:

​```ItemsExampleMod:src/main/java/com/example/ExampleMod.java@AddToItemGroup
​```

Would result in the following markdown:

Extract from file [src/main/java/com/example/ExampleMod.java](${link to github source code}):
```java
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(entries -> {
	entries.addItem(EXAMPLE_ITEM);
});
```​

With the content of ExampleMod.java being:

package com.example.example_mod;

import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.*;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExampleMod implements ModInitializer {
	// @start CreateItem
	public static final Item EXAMPLE_ITEM = new Item(new QuiltItemSettings());
	// @end CreateItem

	@Override
	public void onInitialize(ModContainer mod) {
		LOGGER.info("Hello Quilt world from {}!", mod.metadata().name());

		// @start RegisterItem
		Registry.register(Registries.ITEM, new Identifier(mod.metadata().id(), "example_item"), EXAMPLE_ITEM);
		// @end RegisterItem
		// @start AddToItemGroup
		ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(entries -> {
			entries.addItem(EXAMPLE_ITEM);
		});
		// @end AddToItemGroup
	}
}
@anonymous123-code anonymous123-code added the enhancement New feature or request label Dec 2, 2023
@pyrox0
Copy link

pyrox0 commented Mar 18, 2024

I'll be working on this! I've got a few implementation ideas and I'll try to get a prototype out soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants