hugeblank / allium-cc

Minecraft plugin loader for ComputerCraft
https://hugeblank.github.io/allium-cc-wiki/
MIT License
8 stars 2 forks source link

Information standard formatting #12

Closed hugeblank closed 5 years ago

hugeblank commented 5 years ago

So, in aaa9c41f86263c536d24e8595ff14993fee9cfcf I updated the information standard format to be as follows: For a command with a usage of "!help [plugin id | command tag | page number] [page number]":

local helpInfo = {
  generic = "Demo help command",
  plugin = {
    optional = true,
    generic = "Plugin ID",
    page = {
      optional = true,
      generic = "Page number"
    }
  },
  command = {
    optional = true,
    generic = "Command tag, Ex: (!allium:help)",
    page = {
      optional = true,
      generic = "Page number"
    }
  },
  page = {
    optional = true,
    generic = "Page number"
  }
}

Where: generic is the information of the parameter optional is a parameter that is completely optional (An example of this is a page number, see above.) noclick is a parameter that is required, but not specifically the name of the parameter. (An example of this is when the parameter is a username. You can't just plonk a username in.)

By default parameters can be clicked on to automatically load them into the chat input, thus the need for the optional and noclick tags.

Here is a demo of the table in action:

image

There is a lot of repetition going on here, and I'm wondering if anyone could propose a better method to write this information, preferably one where a usage string could be derived.

(And yes I know the example could be simplified like this):

local page = {
  optional = true,
  generic = "Page number"
}
local helpInfo = {
  generic = "Demo help command",
  plugin = {
    optional = true,
    generic = "Plugin ID",
    page = page
  },
  command = {
    optional = true,
    generic = "Command tag, Ex: (!allium:help)",
    page = page
  },
  page = page
}
hugeblank commented 5 years ago

I've had a thunk or three about this and I came up with an improvement. generic is totally not necessary, it could just not have a key associated to it, and be seen as [1] within the table. This is the only tag that makes sense to remove, since it's used so often. Meta tags like optional and noclick will stick around. I think.

This is what the demonstrated table (uncondensed) would look like without the generic tag:

local helpInfo = {
  "Demo help command",
  plugin = {
    optional = true,
    "Plugin ID",
    page = {
      optional = true,
      "Page number"
    }
  },
  command = {
    optional = true,
    "Command tag, Ex: (!allium:help)",
    page = {
      optional = true,
      "Page number"
    }
  },
  page = {
    optional = true,
    "Page number"
  }
}

...you probably could have visualized that without this demo.

This revelation has been pushed to the unstable branch, however this RFC still stands. Better exists, I just have yet to come up with it.

hugeblank commented 5 years ago

After doing a bit more tweaking and work, I pushed 647c257affdb3fb79c2cf066e82d3727e09e342f a couple of days ago. This brings several changes which I cover in the Unstable documentation of the wiki. I will reiterate here:

hugeblank commented 5 years ago

Going to close this now since I think the format is as good as it will get. If anymore revelations occur to me, depending on the severity of them, I'll be sure to either reopen this discussion or open a new one