Alexis
Alexis

Reputation: 854

How to point Stata at the same help file for two different commands?

Stata's swilk command performs the Shapiro-Wilk test for non-normality. Likewise, Stata's sfrancia performs the Shapiro-Francia test for non-normality. However, both commands share the same help file swilk.sthlp.

How does Stata know that a single help file serves for more than one command? For example, how does Stata know that swilk.sthlp holds the correct response to the command help sfrancia? Or that ttest.sthlp holds the correct response for help ttesti (not just help ttest)?

I am writing a new package for which the same help file should similarly serve for more than one command, and want to be sure I get it right.

Upvotes: 1

Views: 165

Answers (1)

Nick Cox
Nick Cox

Reputation: 37278

StataCorp's own signposting pointing a call for help elsewhere is in recent versions typically done by .maint files. Thus

viewsource shelp_alias.maint 

contains a list of various pointers from names starting with s, including allowed abbreviations, and help sfrancia can be seen to fire up help swilk. For s substitute any other pertinent initial letter.

To see where such a file lurks on your system, use which

which shelp_alias.maint 

The historic system and one that is easy for user-programmers to emulate is that a help file which is named foo.sthlp and contains the single line

.h bar 

is equivalent to a direct help bar. So if you type

. help foo 

it is exactly as if you had known to type

 . help bar 

This system predate the introduction of SMCL and no SMCL directives are to be used.

In summary: a file such as foo.sthlp simply points at bar.sthlp and is not a complete help file.

More on .maint files: Essentially user-programmers should ignore them as far as their own packages are concerned. Otherwise every user would be committed to editing the .maint file concerned on every system they used, which might not even be allowed locally, and to doing that on each upgrade of Stata. Further, StataCorp might use some different system in future versions. In contrast, the .h mechanism has been used for so long and been publicised so much that it is safe to bet that it will work indefinitely.

Note: Stata help files were originally labelled with the extension .hlp. When Stata was started in 1985, compatibility with the existing DOS rule that file extensions could not exceed 3 characters in length was vital. Later Windows adopted precisely the same extension for its help files, and given such force majeure Stata introduced .sthlp files in version 10. Stata can naturally still read .hlp files that are text files in appropriate directories or folder, i.e. along the defined adopath.

Upvotes: 2

Related Questions