Commit c1c03ab2 authored by Eirik Alvær's avatar Eirik Alvær
Browse files

updated help texts

parent 322d3386
......@@ -3,102 +3,171 @@
function CommandExecutor() {
"use strict";
var helpTexts = {
'help': {
'description': 'Prints help for one of these commands:',
'syntax': '[help-topic]',
'examples': [
"correlate": {
"parameters": "varlist [if]",
"shortDescription": "Generates a correlation matrix.",
"description": "The correlate command displays the correlation matrix for a group of variables. The varlist is mandatory. ",
"syntax": "correlate varlist [if]",
"examples": [
{
'example': 'help tabulate',
'description': 'Provides help about the tabulate function'
"example": "correlate gender age income",
"description": "Three-way correlation matrix"
},
{
'example': 'help correlate',
'description': 'Provides help about the correlate function'
"example": "correlate age income if gender == 'male'",
"description": "Two-way correlation matrix with conditional expression "
}
],
'relatedcommands': ["describe", "topics", "tabulate", "correlate", "help", "drop", "summarize"]
]
},
'topics': {
'description': 'lists topics and variables within each topic',
'syntax': '[topic-name]',
'examples': [
"describe": {
"parameters": "[varlist]",
"shortDescription": "Lists variables from the current dataset.",
"description": "The command describe displays variables along with available metadata from the current dataset. If [varlist] is not specified, all variables in the dataset are displayed. To get metadata for specific variables, they need to be specified.",
"syntax": "describe [varlist]",
"examples": [
{
'example': 'topics',
'description': 'List all topics in the data collection'
"example": "describe",
"description": "List all variables and variable metadata in the current dataset"
},
{
'example': 'topics \'employment\'',
'description': 'List sub-topics and variables for a specified topic'
"example": "describe gender age income",
"description": "List variable properties for three variables"
}
]
},
'describe': {
'description': 'lists variables and variable properties from the current dataset',
'syntax': '[varlist]',
'examples': [
"drop": {
"parameters": "[varlist] [if]",
"shortDescription": "Removes variables or observations from the current dataset.",
"description": "The command drop removes variables or observations from the current dataset. Either the [varlist] or the [if] statement need to be specified. Both can not be specified together. When the [varlist] is specified the variable column is removed from the dataset. And, when the [if] statement is specified, observations (rows) matching the condition are removed from the dataset.\n\nThe drop command is irreversible.",
"syntax": "drop [varlist] [if]",
"examples": [
{
'example': 'describe',
'description': 'List all variables and variable properties in the current dataset'
"example": "drop gender",
"description": "Remove variable “gender” from the current dataset."
},
{
'example': 'describe gender age income',
'description': 'List variable properties for three variables'
"example": "drop if age < 5",
"description": "Remove observations where variable age has value less than 5."
}
]
},
'variables': {
'description': 'lists variables and variable properties from the data collection',
'syntax': '[varlist]',
'examples': [
"generate": {
"parameters": "newvar = expression [if ...]",
"shortDescription": "Creates new variable as per the expression defined. CURRENTLY NOT SUPPORTED",
"description": "The command generate creates a new variable where its values are as per the expression defined.\n\nThe type of new variable will be determined by the result returned by the expression.\nThe arithmetic functions supported are +, - , *, / and ^ . \n\nCURRENTLY NOT SUPPORTED",
"syntax": "generate newvar =exp [if ...]",
"examples": [
{
'example': 'variables',
'description': 'List all variables and variable properties in the data collection'
"example": "generate fakeVar = age + 5",
"description": "Create a variable called "fakeVar". The value for each case will be the value of variable age plus five."
},
{
'example': 'variables gender age income',
'description': 'List variable properties for three variables'
"example": "generate fakeVar = age + 5 if gender = 0",
"description": "as above, but only when gender is equal to zero. Value of fakeVar will otherwise be missing"
}
]
},
"help": {
"parameters": "commandName",
"shortDescription": "Displays documentation of the command.",
"description": "The commands supported are:",
"syntax": "help commandName",
"examples": [
{
"example": "help tabulate",
"description": "Documentation of the tabulate command is displayed."
}
]
},
'tabulate': {
'description': 'generate tables of frequencies with one or more variables',
'syntax': 'varname1 [varname2] [if] [, options]',
'examples': [
"import": {
"parameters": "registervar timestamp [as] [newvar]",
"shortDescription": "Creates a new status variable from the register variable.",
"description": "The command import creates a new status variable in the current dataset from the register variable at the specified timestamp. When the new status variable name is not specified, a default name is assigned.",
"syntax": "import registervar timestamp [as] [newstatusvar]",
"examples": [
{
'example': 'tabulate gender age',
'description': 'Two-way tabulation'
"example": "import UTVALG_WLONN '2011-11-11'",
"description": "A new status variable with default name is created from the register variable UTVALG_WLONN with timestamp ‘2011-11-11’"
},
{
'example': 'tabulate gender age, summarize(income)',
'description': 'Two-way tabulation with included summary statistics for income'
"example": "import F_REHAB_INNV_GRAD '2011-11-11' as rehab2011",
"description": "A new status variable with rehab2011 as name is created from the register variable F_REHAB_INNV_GRAD with timestamp ‘2011-11-11’"
}
]
},
"recode": {
"parameters": "varlist (rule) [(rule) ...] [, generate(newvar)]",
"shortDescription": "Recode categorical variables. CURRENTLY NOT SUPPORTED",
"description": "The command recode creates a new status variable in the current dataset from the existing status variable where its values are as per the specified rules. Values that do not meet any of the conditions of the rules are left unchanged, unless an otherwise rule is specified. When the new status variable name is not specified, a default name is assigned.",
"syntax": "recode varlist rule [(rule) ...] [, generate(newvar)]",
"examples": [
{
"example": "recode v001 (1 3 = 1) (4/7 = 2) (missing = .) (* = 9), gen(v001b)",
"description": "recode v001 so that values 1 and 3 are recoded to 4,\nvalues 4 through 7 are recoded to 2,\nall missing values are recoded to sysmiss and\nall other values (including 2) are recoded to 9.\nCURRENTLY NOT SUPPORTED"
}
]
},
'correlate': {
'description': 'generate a correlation matrix',
'syntax': '[varlist] [if]',
'examples': [
"summarize": {
"parameters": "varlist [if]",
"shortDescription": "List summary statistics for variables.",
"description": "The command summarize displays univariant summary statistics of the status variables. If no varlist is specified then summary statistics for all variables in current dataset are displayed. When a condition is specified the summary is displayed only if it is met.",
"syntax": "summarize varlist [if]",
"examples": [
{
'example': 'correlate gender age income',
'description': 'Three-way correlation matrix'
"example": "summarize age income",
"description": "Display summary statistics for two variables"
},
{
'example': 'correlate age income if gender == \'male\'',
'description': 'Two-way correlation matrix with conditional expression'
"example": "summarize age income if age > 45",
"description": "Display summary statistics for two variables with a conditional expression"
}
]
},
'summarize': {
'description': 'list summary statistics for variables',
'syntax': '[varlist] [if]',
'examples': [
"tabulate": {
"parameters": "varname1 [varname2] [if]",
"shortDescription": "Generate tables of frequencies with one or more variables.",
"description": "The command tabulate displays univariant summary statistics of the status variables. When a condition is specified the subset of the cases that match the condition are displayed.",
"syntax": "tabulate varname1 [varname2] [if]",
"examples": [
{
'example': 'summarize age income',
'description': 'List summary statistics for two variables'
"example": "tabulate gender age",
"description": "Two-way tabulation"
},
{
'example': 'summarize age income if age > 45',
'description': 'List summary statistics for two variables with a conditional expression'
"example": "tabulate gender age if age > 5",
"description": "Two-way tabulation with a conditional expression."
}
]
},
"topics": {
"parameters": "[topiclist]",
"shortDescription": "Displays topics and register variables within each topic.",
"description": "The command topics displays topics along with their metadata. When a topiclist is specified topic metadata along with the register variables within it are displayed.",
"syntax": "topics [topiclist]",
"examples": [
{
"example": "topics",
"description": "Displays all topics along with metadata."
},
{
"example": "topics ‘demography’",
"description": "Displays metadata for the specified topic along with sub-topics and register variables within it."
}
]
},
"variables": {
"parameters": "[regvarlist]",
"shortDescription": "Displays register variables.",
"description": "The command variables displays register variables along with their metadata. When a regvarlist is specified metadata for them is displayed.",
"syntax": "variables [regvarlist]",
"examples": [
{
"example": "variables",
"description": "Displays all register variables along with their metadata."
},
{
"example": "variables F_REHAB_INNV_GRAD UTVALG_WLONN",
"description": "Displays metadata for the specified register variables."
}
]
}
......@@ -126,6 +195,14 @@ function CommandExecutor() {
});
};
function addHelpCommands(helpText) {
helpCommands = helpTexts.keys();
helpCommands.sort();
helpCommands.forEach(function (helpCommand) {
helpText.description += " " + helpCommand;
})
}
return {
//Eww! This method should not be exported, but it has to be done to
//enable mocking for the tests
......@@ -145,6 +222,9 @@ function CommandExecutor() {
switch (parserObject.type) {
case "help":
helpText = helpTexts[parserObject.helpTopic || "help"];
if (!parserObject.helpTopic) {
addHelpCommands(helpText);
}
intermediateResult = new Promise(function (resolve) {
resolve(helpText ?
{result: helpText} :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment