Skip to content

Commit ca1b8a2

Browse files
committed
Write a few more sections in `README.adoc'.
1 parent 0e79538 commit ca1b8a2

File tree

1 file changed

+199
-24
lines changed

1 file changed

+199
-24
lines changed

README.adoc

Lines changed: 199 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
:toc: macro
22
:toc-title: Table of contents
33
ifndef::env-github[:icons: font]
4+
ifdef::env-github[]
5+
:warning-caption: :warning:
6+
:caution-caption: :fire:
7+
:important-caption: :exclamation:
8+
:note-caption: :paperclip:
9+
:tip-caption: :bulb:
10+
endif::[]
411

512
= Eldev
613

@@ -286,6 +293,12 @@ should really remain your own private setting and go to `Eldev-local`.
286293
Local dependencies have _loading modes_, just as the project’s package
287294
itself. Those will be discussed later.
288295

296+
Eldev correctly handles situations with changing definitions of local
297+
dependencies. I.e. by simply commenting out or uncommenting
298+
`eldev-use-local-dependency` call, you can quickly test your project
299+
both with a Melpa-provided package and with a local dependency — Eldev
300+
will adapt without any additional work from you.
301+
289302
[#additional-dependencies]
290303
=== Additional dependencies
291304

@@ -425,33 +438,143 @@ it only knows how to build packages, byte-compile `.el` files and make
425438
can do anything you want. For example, generate resource files that
426439
should be included in the final package.
427440

441+
The main command is predictably called `build`. There are also
442+
several related commands which will be discussed in the next sections.
443+
428444
=== Targets
429445

430446
Build system is based on _targets_. Targets come in two kinds: _real_
431447
and _virtual_. First type of targets corresponds to files — not
432-
necessarily existing, but they will be generated when such targets are
433-
built. Targets of the second type always have names that begin with
434-
“:” (like keywords in Elisp). Most import virtual target is called
435-
`:default` — this is what Eldev will build if you don’t request
436-
anything explicitly.
448+
necessarily already existing. When needed, such targets get rebuilt
449+
and the files are (re)generated in process. Targets of the second
450+
type always have names that begin with “:” (like keywords in Elisp).
451+
Most import virtual target is called `:default` — this is what Eldev
452+
will build if you don’t request anything explicitly.
453+
454+
To find all targets in a project (more precisely, its `main`
455+
<<target-sets,target set>>):
456+
457+
$ eldev targets
458+
459+
Project’s targets form a tree. Before a higher-level target can be
460+
built, all its children must be up-to-date, i.e. built first if
461+
necessary. In the tree you can also see _sources_ for some targets.
462+
Those can be distinguished by lack of builder name in brackets.
463+
Additionally, if output is colored, targets have special color, while
464+
sources use default text color.
465+
466+
Here is how target tree looks for Eldev project itself (version may be
467+
different and more targets may be added in future):
468+
469+
:default
470+
bin/eldev [SUBST]
471+
bin/eldev.in
472+
:package
473+
dist/eldev-0.1.tar [PACK]
474+
bin/eldev [repeated, see above]
475+
eldev-ert.el
476+
eldev-util.el
477+
eldev.el
478+
:compile
479+
eldev-ert.elc [ELC]
480+
eldev-ert.el
481+
eldev-util.elc [ELC]
482+
eldev-util.el
483+
eldev.elc [ELC]
484+
eldev.el
485+
:package-archive-entry
486+
dist/eldev-0.1.entry [repeated, see ‘dist/eldev-0.1.tar’ above]
487+
488+
And a short explanation of various elements:
489+
490+
`:default`, `:package`, `:compile` etc.::
491+
492+
Virtual targets. The ones you see above are typical, but there
493+
could be more.
494+
495+
`bin/eldev`, `dist/eldev-0.1.tar`, `eldev-ert.elc` etc.::
496+
497+
Real targets.
498+
499+
`SUBST`, `PACK`, `ELC`::
500+
501+
Builders used to generate target. Note that virtual targets never
502+
have builders. `SUBST` is not a standard builder, it is defined
503+
in file `Eldev` of the project.
504+
505+
`bin/eldev.in`, `eldev-ert.el` etc.::
506+
507+
Sources for generating targets. Certain targets have more than
508+
one source file. Also note how targets can have other targets as
509+
their sources (`bin/eldev` is both a target on its own and a
510+
source for `dist/eldev-0.1.tar`).
511+
512+
`[repeated \...]`::
513+
514+
To avoid exponential increase in tree size, Eldev doesn’t repeat
515+
target subtrees. Instead, only root target of a subtree is
516+
printed.
517+
518+
==== Target cross-dependencies
437519

438520
FIXME
439521

522+
[#target-sets]
440523
==== Target sets
441524

442525
Eldev groups all targets into _sets_. Normally, there are only two
443526
sets called `main` and `test`, but you can define more if you need
444-
(see variable `eldev-filesets').
527+
(see variable `eldev-filesets'). For example, if your project
528+
includes a development tool that certainly shouldn’t be included in
529+
project’s package, it makes sense to break it out into a separate
530+
target set.
531+
532+
Target sets should be seen only as ways of grouping targets together
533+
for the purpose of quickly enumerating them. Two targets in the same
534+
set can be completely independent from each other. Similarly, targets
535+
from different sets can depend on each other (provided this doesn’t
536+
create a circular dependency, of course). For example, targets in set
537+
`test` will often depend on those in set `main`, because test `.el`
538+
files usually `require` some features from `main`.
539+
540+
By default, command `build` operates only on `main` target set. You
541+
can use option `--set` (`-s`) to process a different target set. If
542+
you want to build several sets at once, repeat the option as many
543+
times as needed. Finally, you can use special name `all` to order
544+
Eldev to operate on all defined sets at once.
545+
546+
Command `targets` instead of the option expects set names as its
547+
arguments. For example:
548+
549+
$ eldev targets test
445550

446-
FIXME
551+
=== Building packages
447552

448-
=== Cleaning
553+
To build a Elisp package out of your project, use command `package`:
449554

450-
FIXME
555+
$ eldev package
451556

452-
=== Building packages
557+
This command is basically a wrapper over the build system, it tells
558+
the system to generate virtual target `:package`. However, there are
559+
a few options that can only be passed to this special command, not to
560+
underlying `build`.
453561

454-
FIXME
562+
Normally, packages are generated in subdirectory `dist` (more
563+
precisely, in directory specified by `eldev-dist-dir` variable). If
564+
needed, you can override this using `--output-dir` option.
565+
566+
By default, Eldev will use package’s self-reported version, i.e. value
567+
of “Version” header in its main `.el` file. If you need to give the
568+
package a different version, use option `--force-version`. E.g. Melpa
569+
would do this if it used Eldev.
570+
571+
Finally, if you are invoking Eldev from a different tool, you might be
572+
interested in option `--print-filename`. When it is specified, Eldev
573+
will print absolute filename of the generated package and word
574+
“generated” or “up-to-date” as the two last lines of its (stdout)
575+
output. Otherwise it is a bit tricky to find the package, especially
576+
if you don’t use `--force-version` option. As an optimisation, you
577+
can also reuse previous package file if Eldev says “up-to-date”.
455578

456579
=== Byte-compiling
457580

@@ -468,9 +591,12 @@ You can also byte-compile specific files:
468591

469592
Eldev will not recompile `.el` that have up-to-date `.elc` versions.
470593
So, if you issue command `compile` twice in a row, it will say:
471-
“Nothing to do” the second time. But suppose file `foo-misc.el` has
472-
form `(require 'foo-util)`. If you edit `foo-util.el`, byte-compiled
473-
file `foo-misc.elc` might no longer be correct, because it has been
594+
“Nothing to do” the second time.
595+
596+
However, simple comparison of modification time of `.el` and its
597+
`.elc` file is not always enough. Suppose file `foo-misc.el` has form
598+
`(require 'foo-util)`. If you edit `foo-util.el`, byte-compiled file
599+
`foo-misc.elc` might no longer be correct, because it has been
474600
compiled against old definitions from `foo-util.el`. Luckily, Eldev
475601
knows how to detect when a file ``require``s another. You can see
476602
this in the target tree:
@@ -487,14 +613,14 @@ As a result, if you now edit `foo-util.el` and issue `compile` again,
487613
both `foo-util.elc` and `foo-misc.elc` will be rebuilt.
488614

489615
Eldev treats warnings from Emacs’ byte-compiler just as that —
490-
warnings, i.e. they will not prevent compilation from generally
491-
succeeding. However, during automated testing you might want to check
492-
that there are no warnings. The easiest way to do it is to use
493-
`--warnings-as-errors` option (`-w`):
616+
warnings, i.e. they will be shown, but will not prevent compilation
617+
from generally succeeding. However, during automated testing you
618+
might want to check that there are no warnings. The easiest way to do
619+
it is to use `--warnings-as-errors` option (`-w`):
494620

495621
$ eldev compile --warnings-as-errors
496622

497-
Command `compile` is actually just a wrapper over the generic building
623+
Command `compile` is actually only a wrapper over the generic building
498624
system. You can rewrite all the examples above using command `build`.
499625
If you don’t specify files to compile, virtual target `:compile` is
500626
built. This target depends on all `.elc` files in the project.
@@ -562,6 +688,10 @@ with option `-v` or `-t` to see it):
562688
Byte-compiling file ‘foo-util.el’ early as ‘require’d from another file...
563689
Done building “sources” for virtual target ‘:compile’
564690

691+
=== Cleaning
692+
693+
FIXME
694+
565695

566696
== Testing
567697

@@ -847,12 +977,12 @@ Eldev also supports composite filesets. They are built using common
847977
set/logic operations and can be nested, i.e. one composite fileset can
848978
include another. There are currently three types:
849979

850-
`(:and ELEMENT...)`::
980+
`(:and ELEMENT\...)`::
851981

852982
A file matches an `:and` fileset if and only if it matches _every_
853983
of its `ELEMENT` filesets.
854984

855-
`(:or ELEMENT...)`::
985+
`(:or ELEMENT\...)`::
856986

857987
A file matches an `:or` fileset if and only if it matches _at least
858988
one_ of its `ELEMENT` filesets.
@@ -888,16 +1018,61 @@ evaluated in turn — and so on, until everything is resolved.
8881018

8891019
== Extending Eldev
8901020

891-
FIXME
1021+
Eldev is written to be not just configurable, but also extensible. It
1022+
makes perfect sense to have additional code in file `Eldev` — if your
1023+
project has uncommon building steps. And also in `~/.eldev/config` —
1024+
if you want a special command for your own needs, for example. Or
1025+
maybe in `Eldev-local` — if you need something extra only for one
1026+
specific project.
8921027

8931028
=== Hooks
8941029

1030+
Eldev defines a few hooks (more might be added later).
1031+
1032+
`eldev-executing-command-hook`::
1033+
1034+
Run before executing any command. Command name (as a symbol) is
1035+
passed to the hook’s functions as the only argument. This is
1036+
always the “canonical” command name, even if it is run using an
1037+
alias.
1038+
1039+
`eldev-COMMAND-hook`::
1040+
1041+
Run before executing specific command, functions have no
1042+
arguments. Eldev itself uses it (i.e. in its file `Eldev`) to
1043+
print a disclaimer about its fairly slow tests.
1044+
1045+
=== Writing builders
1046+
8951047
FIXME
8961048

897-
=== Adding commands
1049+
=== Adding commands and options
8981050

8991051
FIXME
9001052

901-
=== Adding command and global options
1053+
=== Custom test runners
9021054

9031055
FIXME
1056+
1057+
1058+
== Influential environment variables
1059+
1060+
A few environment variables can affect Eldev’s behavior.
1061+
1062+
`EMACS` or `ELDEV_EMACS`::
1063+
1064+
Use given Emacs executable (also for any child processes). If not
1065+
specified, this defaults to just `emacs`, which is expected
1066+
somewhere in `$PATH`.
1067+
1068+
`ELDEV_LOCAL`::
1069+
1070+
Load Eldev Elisp code from given directory (usually a Git clone of
1071+
source tree) instead of the normal bootstrapping from Melpa.
1072+
Should not be needed normally, only when developing Eldev itself.
1073+
1074+
`ELDEV_DIR`::
1075+
1076+
Directory where user’s configuration file, Eldev’s bootstrapping
1077+
files etc. are located, defaults to `~/.eldev`. Used by Eldev’s
1078+
own regression tests, should be of no interest for typical use.

0 commit comments

Comments
 (0)