From 002a11e7bdfe0c2d3d80d721a851fb45e2fcff98 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 22 May 2014 08:16:55 -0500 Subject: Update docs for example and pending directories. --- www/code.html | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'www/code.html') diff --git a/www/code.html b/www/code.html index faa718ca..9f5845fe 100755 --- a/www/code.html +++ b/www/code.html @@ -112,8 +112,8 @@ multiple commands:
  • lib/dirtree.c
  • The toys directory contains the C files implementating -each command. Currently it contains three subdirectories: -posix, lsb, and other.
  • +each command. Currently it contains five subdirectories categorizing the +commands: posix, lsb, other, example, and pending.
  • The scripts directory contains the build and test infrastructure.
  • The kconfig directory contains the configuration @@ -130,27 +130,41 @@ all the information it needs (such as command line arguments) from specially formatted comments and macros in the C file. (See the description of the "generated" directory for details.)

    -

    Currently there are three subdirectories under "toys", one for commands +

    Currently there are five subdirectories under "toys", one for commands defined by the POSIX standard, one for commands defined by the Linux Standard -Base, and one for all other commands. (This is just for developer convenience -sorting them, the directories are otherwise functionally identical.)

    - -

    An easy way to start a new command is copy the file "toys/other/hello.c" to -the name of the new command, and modify this copy to implement the new command. -This file is an example command meant to be used as a "skeleton" for -new commands (more or less by turning every instance of "hello" into the +Base, an "other" directory for commands not covered by an obvious standard, +a directory of example commands (templates to use when starting new commands), +and a "pending" directory of commands that need further review/cleanup +before moving to one of the other directories (run these at your own risk, +cleanup patches welcome). +These directories are just for developer convenience sorting the commands, +the directories are otherwise functionally identical. To add a new category, +create the appropriate directory with a README file in it whose first line +is the description menuconfig should use for the directory.)

    + +

    An easy way to start a new command is copy the file "toys/example/hello.c" +to the name of the new command, and modify this copy to implement the new +command (more or less by turning every instance of "hello" into the name of your command, updating the command line arguments, globals, and -help data, and then filling out its "main" function with code that does -something interesting). It provides examples of all the build infrastructure -(including optional elements like command line argument parsing and global -variables that a "hello world" program doesn't strictly need).

    +help data, and then filling out its "main" function with code that does +something interesting).

    + +

    You could also start with "toys/example/skeleton.c", which provides a lot +more example code (showing several variants of command line option +parsing, how to implement multiple commands in the same file, and so on). +But usually it's just more stuff to delete.

    Here's a checklist of steps to turn hello.c into another command:

    Headers.

    -- cgit v1.2.3