Code Review from @dom96
This commit is contained in:
parent
183fed527b
commit
2a7e1f132c
2 changed files with 6 additions and 25 deletions
|
|
@ -429,7 +429,7 @@ which are also useful. Take a look at it for more information.
|
|||
|
||||
### Project structure
|
||||
|
||||
A Nimble project includes a *source directory*, containing a at most one
|
||||
A Nimble project includes a *source directory*, containing at most one
|
||||
primary source file, which shares the same name as the project itself (as well
|
||||
as the project's nimble file). In most cases this source directory will also be
|
||||
the root directory of the whole project. In all cases, the root directory will
|
||||
|
|
@ -457,27 +457,6 @@ Here's a sample one-module project directory:
|
|||
└── tests.nim
|
||||
```
|
||||
|
||||
Here's a more complex example:
|
||||
|
||||
```
|
||||
. # Root directory
|
||||
├── my_project.nimble # Nimble file
|
||||
├── nim_src # Source directory
|
||||
│ ├── my_project.nim # Primary source file
|
||||
│ ├── my_project # Secondary source directory
|
||||
│ │ ├── util.nim
|
||||
│ │ ├── common.nim
|
||||
│ └── tests # Excluded directory
|
||||
│ ├── nim.cfg
|
||||
│ └── tests.nim
|
||||
├── README.rst
|
||||
└── Makefile
|
||||
```
|
||||
|
||||
In this example, the source directory is specified in the .nimble file
|
||||
with `srcDir = "nim_src"`. Inside of `my_project.nim`, the `util` and `common`
|
||||
modules will be imported as `my_project.util` and `my_project.common`.
|
||||
|
||||
#### Tests
|
||||
|
||||
A common problem that arises with tests is the fact that they need to import
|
||||
|
|
@ -534,7 +513,7 @@ If your package exposes multiple modules then the modules should be in a
|
|||
from other packages which expose modules with the same names. In this case
|
||||
the package's modules will be imported with ``import PackageName/module``.
|
||||
|
||||
Here's a simple example multi-module library package:
|
||||
Here's a simple example multi-module library package called `util`:
|
||||
|
||||
```
|
||||
.
|
||||
|
|
@ -582,6 +561,8 @@ It's a good idea to test that the dependencies you specified are correct by
|
|||
running by running ``nimble build`` or ``nimble install`` in the directory
|
||||
of your package.
|
||||
|
||||
### Hybrids
|
||||
|
||||
One thing to note about binary packages that contain source files aside from
|
||||
the one(s) specified in `bin` (or that also expose multiple library modules, as
|
||||
above) is that a binary may share the name of the package: this will mean
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ proc validatePackageStructure(pkgInfo: PackageInfo, options: Options) =
|
|||
"will be an error in the future.") %
|
||||
[pkgInfo.name, pkgInfo.name & ext, file & ext]
|
||||
hint = ("If this is the primary source file in the package, " &
|
||||
"Rename it to '$1'. If it's a source file required by " &
|
||||
"rename it to '$1'. If it's a source file required by " &
|
||||
"the main module, or if it is one of several " &
|
||||
"modules exposed by '$4', then move it into a '$2' subdirectory. " &
|
||||
"If it's a test file or otherwise not required " &
|
||||
|
|
@ -118,7 +118,7 @@ proc validatePackageStructure(pkgInfo: PackageInfo, options: Options) =
|
|||
let
|
||||
msg = ("Package '$2' has an incorrect structure. " &
|
||||
"It should contain a single directory hierarchy " &
|
||||
"For source files, named '$3', but file '$1' " &
|
||||
"for source files, named '$3', but file '$1' " &
|
||||
"is in a directory named '$4' instead. " &
|
||||
"This will be an error in the future.") %
|
||||
[file & ext, pkgInfo.name, correctDir, dir]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue