-
Notifications
You must be signed in to change notification settings - Fork 1
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
Standardize documentation for things other than functions #1
Comments
This is interesting. I like the idea of documenting more than just functions, but it's not something I've done consistently myself so it's difficult for me to gauge the pros and cons of each approach.
The first approach as you suggest is inherently lacking in that not everything can be targeted this way. However it is has the benefit of being right where a human would probably expect it to be in the cases where it does apply, and could be used as an optional replacement for things like declaration macros. Something else I want to comment on here is that I feel it's somewhat redundant to include the prefix (e.g. "scoreboard"), because the type of declaration can be inferred from the defining command that is required to immediately follow. With this generalization in mind, the special case for functions could become "the first block comment in the function, if it is not already a declaration for something else."
The second approach sounds like it would work for all current and future types of resources, as well as anything else we want to target such as objectives, entity tags, and teams. It feels the most "out of the way" in that it doesn't require integration with existing vanilla resources and can be done fully externally and optionally. That's not necessarily all good, though, as it does require more time and effort to maintain separate files with a different syntax/schema. This approach also raises questions regarding the file/directory structure and how the custom files are expected to be organized.
The third approach covers some of the remaining cases that the first approach naturally cannot, but it requires inventing an "intrusive" JSON sub-schema specifically for the documentation format. I'm mostly undecided whether this approach is worthwhile in light of the second approach... but, in the interest of human convenience (i.e. being able to embed the documentation directly within the resource itself), I think there's a fair argument for having this approach as an option as well. |
So, I thought a little more about this, and there seem to be 2 types of things to document. But then there are things which don't share this property, and the 1st and 3rd method cannot be directly applied. For example, for tags or storages, you can just add arbitary tag names and write to arbitary storages. So, this raises the question, if it might make sense to separate declaring IMP doc from simple documenting IMP doc, or if IMP doc should even cover these cases. Dph+ solves this with the I am unsure what the best solution is for this, maybe just a beginning that's different from
Well, the act of saying the name of the thing you are documenting is also kind of redundant. Btw, why is that needed in the definition?
Yeah, that's also something I thought about and I'm not really sure about. You could just put one file in each directory listing all the definitions, but that might not be very handy, and maybe you want to separate different kinds of definitions instead.
I don't really know what would be intrusive about it, could you perhaps elaborate on that a bit more? It also might make sense to ask a bit around on MCC to see what others think of this. |
Fair point. The original motivating reason for function headers at the top of the file was to be able to easily copy-paste the function name into a function command. This was also an inspiring reason for the way the
By "intrusive" I basically just meant "not part of the actual vanilla resource" since we'd need to add our own extra, custom data to the file and we can't ever be absolutely 100% certain this won't cause conflicts in the future. IIRC some third-party tools like Blockbench have done this for comments and credit tags without issue for years, so by no means do I think it's a deal-breaker.
Yeah, that's more-or-less what I was thinking while writing my thoughts about the second approach being the most generic. Were I to define these with a macro somewhere I'd probably do it in the setup/init/install function, but that's still an arbitrary choice and difficult to concretely define exactly what is a "setup" function.
Right. It might make sense to declare the existence of something without documenting it, but I can't think of any case where you can document something that hasn't been declared. So I do think it would be useful to be able to both declare the existence of something at the same as documenting it, instead of having to take those two actions separately.
Possibly. I remember suggesting a similar idea about using a different block comment prefix to denote documentation vs just a header comment, here: SpyglassMC/Spyglass#802 (comment) People like to use An alternative to what's mentioned in that link: keep |
Well, it's basically the same idea as IMP's custom item tags. You just add a underscore as first char, or even multiple, to make it pretty certain even with Mojang's non-existing conventions, you don't get a conflict.
Yeah, that's my thinking as well. Of course when in doubt you could create a dummy mcfunction file with only such declarations, but that's approach #2 again through the backdoor.
Also, one more thought. This is example kind of unfortunate, if at the beginning of the function file #>
# Main scoreboard
# @internal
scoreboard objectives add 91.ns.main There could be a situation where you don't want to document the function, but you do want to document something you are declaring in the first line. |
I think the solution here is to define separate a prefix for each required behaviour. So probably keep |
(cc @NeunEinser @SPGoding) Coming back to this after a while, I see three distinct cases here: 1. Comment headingsFor highlighting arbitrary text and creating a visual indicator: #> Count the number of players and store the result.
execute store result score $players my.score if entity @a Based on what I see in the wild, this is how most people use 2. Function headersAs IMP-Doc describes, "a series of comments that describe [a function's] purpose, context, and interface:" #> imp:core/load
#
# Main loading procedure with the core entity as context.
#
# Anything branching from here can use `@s` instead of the core UUID.
#
# @context core These would still be special-cased to the first line of a function to describe the function itself, but with a dedicated comment type there'd be zero ambiguity. For example, this would eliminate the edge-case where "you don't want to document the function, but you do want to document something you are declaring in the first line." We could use I hadn't thought of it before, but 3. DeclarationsPart of the inspiration behind this entire thread, being able to declare and document more than just functions: #> scoreboard 91.ns.main
# The main storage of this data pack
# @internal
scoreboard objectives add 91.ns.main This would provide a solid foundation for future expansion, and, in conjunction with a dedicated function header prefix, would help eliminate ambiguity. We could probably use (Note: this does not account for the various types of JSON resources, only mcfunction comments. Standardizing some form of JSON documentation can be addressed as a potential extension to IMP-Doc following this one.) |
I don't really have much input for this as it just seems like some arbitrary decisions. I will just comply with whatever is specified 👀 |
Sounds good to me. Also, I don't think anyone will/should run an mcfunction file as a shell script ever. This would also require the file's mode to be set executable. I also don't really care about the character, though 😉 |
I recently pushed an update to language-mcfunction (version 0.18.0) that expanded the pool of possible block comment prefix characters. Excerpt from Arcensoth/language-mcfunction#45 (comment):
If/when the |
Have you decided anything about this issue? |
No, and, if anything, I'm further from a decision than I was before. I've done very little related to commands and data packs lately. I would like to find the time to commit to this, but until I can this project is in a state of limbo. IMP was founded on my own personal practices, and I don't want to move forward without being able to back up the decisions with my own experience. |
The current IMP doc only covers documentation for functions.
There are already some extensions to this, for example by Datapack Helper Plus.
I think it would be good to come up with a standard for this before we get more conflicting standards.
Things I think are worth to be documented:
Tags:[]
nbt-tag)Currently, IMP doc has to be in the first line of a function file. For non-function file declarations that doesn't make sense, of course. There are several ways such definitions could be applied.
Right where you execute a defining command
This would still be a function comment and is basically what dph+ does.
Since for functions the first line has to include the function's name, I think it would make sense for other things to do the same.
To be able to know what is defined, I propose using a prefix to the resource location (which is optional for function definitions for backwards compatibility)
Example
Considerations
While this works well for things that are actually defined with a single command, such as objectives, bossbars and teams, other things datapacks use are not defined in such a way, including tags, scoreboard players, storages or any JSON definition.
In order to mitigate this, the restriction that the IMP doc has to appear right above the definition could be removed in this case
In a separate file
With this idea, definitions could be put into a separate file (with a custom extension such as
.imp
or.impdoc
.A file could hold multiple such definitions. This might be nice for giving a good overview of a specific directory, for example, such a file could be present in a
namespace/advancements/...
directory.Example
Considerations
While this might be nice for some things, like giving an overview of declarations in a datapack, It would also allow to separate different definitions, for example by declaring a
tags.impdoc
including all tags. I don't think it should be the only way. Thinking of e.g. java this feels more like an exported form of Javadoc (or impdoc in this case) instead of an in-code documentationIn a non-vanilla JSON tag (for JSON definitions only)
Pretty self-explanatory, just add a custom JSON tag at the beginning of a JSON file
Example
Considerations
I think this works pretty well and should be possible for anything that's defined as JSON, but of course does not work for anything else, so another solution is needed for those cases.
Anything else?
Feel free to add/ discuss other ideas here
The text was updated successfully, but these errors were encountered: