mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-07 04:14:19 +00:00
docgen: module dependencies are now listed
This commit is contained in:
@@ -45,16 +45,12 @@ doc.body_toc = """
|
||||
$tableofcontents
|
||||
<div class="content" id="content">
|
||||
$moduledesc
|
||||
<h1>Dependencies</h1>
|
||||
$deps
|
||||
$content
|
||||
</div>
|
||||
"""
|
||||
|
||||
doc.body_no_toc = """
|
||||
$moduledesc
|
||||
<h1>Dependencies</h1>
|
||||
$deps
|
||||
$content
|
||||
"""
|
||||
|
||||
|
||||
@@ -30,17 +30,11 @@ doc.toc = r"\tableofcontents \newpage"
|
||||
doc.body_toc = """
|
||||
$tableofcontents
|
||||
$moduledesc
|
||||
|
||||
Dependencies: $deps
|
||||
|
||||
$content
|
||||
"""
|
||||
|
||||
doc.body_no_toc = """
|
||||
$moduledesc
|
||||
|
||||
Dependencies: $deps
|
||||
|
||||
$content
|
||||
"""
|
||||
|
||||
|
||||
@@ -70,13 +70,24 @@ However, the generated C code is not platform independent. C code generated for
|
||||
Linux does not compile on Windows, for instance. The comment on top of the
|
||||
C file lists the OS, CPU and CC the file has been compiled for.
|
||||
|
||||
|
||||
Cross compilation
|
||||
=================
|
||||
|
||||
To `cross compile`:idx:, use for example::
|
||||
|
||||
nimrod c --cpu:i386 --os:linux --compile_only --gen_script myproject.nim
|
||||
|
||||
Then move the C code and the compile script ``compile_myproject.sh`` to your
|
||||
Linux i386 machine and run the script.
|
||||
|
||||
|
||||
DLL generation
|
||||
==============
|
||||
|
||||
Nimrod supports the generation of DLLs. However, there must be only one
|
||||
instance of the GC per process/address space. This instance is contained in
|
||||
``nimrtl.dll``. This means that every generated Nimrod DLL depends
|
||||
``nimrtl.dll``. This means that every generated Nimrod `DLL`:idx: depends
|
||||
on ``nimrtl.dll``. To generate the "nimrtl.dll" file, use the command::
|
||||
|
||||
nimrod c -d:release lib/nimrtl.nim
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
## Coding conventions:
|
||||
## ALL types are named the same as in the POSIX standard except that they start
|
||||
## with 'T' or 'P' (if they are pointers) and without the '_t' prefix to be
|
||||
## with 'T' or 'P' (if they are pointers) and without the '_t' suffix to be
|
||||
## consistent with Nimrod conventions. If an identifier is a Nimrod keyword
|
||||
## the \`identifier\` notation is used.
|
||||
##
|
||||
## This library relies on the header files of your C compiler. Thus the
|
||||
## This library relies on the header files of your C compiler. The
|
||||
## resulting C code will just include <XYZ.h> and *not* define the
|
||||
## symbols declared here.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# Nimrod's Runtime Library
|
||||
# (c) Copyright 2010 Andreas Rumpf
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
@@ -69,7 +69,21 @@ when defined(Windows):
|
||||
dwCreationFlags: int32, lpThreadId: var int32): THandle {.
|
||||
stdcall, dynlib: "kernel32", importc: "CreateThread".}
|
||||
|
||||
|
||||
proc winSuspendThread(hThread: TSysThread): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "SuspendThread".}
|
||||
|
||||
proc winResumeThread(hThread: TSysThread): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "ResumeThread".}
|
||||
|
||||
proc WaitForMultipleObjects(nCount: int32,
|
||||
lpHandles: ptr array[0..10, THandle],
|
||||
bWaitAll: int32,
|
||||
dwMilliseconds: int32): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "WaitForMultipleObjects".}
|
||||
|
||||
proc WaitForSingleObject(hHandle: THANDLE, dwMilliseconds: int32): int32 {.
|
||||
stdcall, dynlib: "kernel32", importc: "WaitForSingleObject".}
|
||||
|
||||
else:
|
||||
type
|
||||
TSysLock {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
|
||||
@@ -81,23 +95,20 @@ else:
|
||||
importc: "pthread_mutex_lock", header: "<pthread.h>".}
|
||||
proc Release(L: var TSysLock) {.
|
||||
importc: "pthread_mutex_unlock", header: "<pthread.h>".}
|
||||
|
||||
|
||||
proc pthread_create(a1: ptr TSysThread, a2: ptr int,
|
||||
a3: proc (x: pointer): pointer {.noconv.},
|
||||
a4: pointer): cint {.importc: "pthread_create",
|
||||
header: "<pthread.h>".}
|
||||
proc pthread_join(a1: TSysThread, a2: ptr pointer): cint {.
|
||||
importc, header: "<pthread.h>".}
|
||||
|
||||
|
||||
type
|
||||
TThread* = TSysThread
|
||||
TLock* = TSysLock
|
||||
TThreadFunc* = proc (closure: pointer) {.cdecl.}
|
||||
|
||||
#DWORD WINAPI SuspendThread(
|
||||
# __in HANDLE hThread
|
||||
#);
|
||||
#DWORD WINAPI ResumeThread(
|
||||
# __in HANDLE hThread
|
||||
#);
|
||||
#DWORD WINAPI ThreadProc(
|
||||
# __in LPVOID lpParameter
|
||||
#);
|
||||
|
||||
proc createThread*(t: var TThread, fn: TThreadFunc, closure: pointer) =
|
||||
when defined(windows):
|
||||
nil
|
||||
|
||||
@@ -280,6 +280,7 @@ type
|
||||
skParam, # a parameter
|
||||
skGenericParam, # a generic parameter; eq in ``proc x[eq=`==`]()``
|
||||
skTemp, # a temporary variable (introduced by compiler)
|
||||
skModule, # module identifier
|
||||
skType, # a type
|
||||
skConst, # a constant
|
||||
skVar, # a variable
|
||||
@@ -293,7 +294,6 @@ type
|
||||
skField, # a field in a record or object
|
||||
skEnumField, # an identifier in an enum
|
||||
skForVar, # a for loop variable
|
||||
skModule, # module identifier
|
||||
skLabel, # a label (for block statement)
|
||||
skStub # symbol is a stub and not yet loaded from the ROD
|
||||
# file (it is loaded on demand, which may mean: never)
|
||||
|
||||
@@ -32,7 +32,6 @@ type
|
||||
filename*: string # filename of the source file; without extension
|
||||
basedir*: string # base directory (where to put the documentation)
|
||||
modDesc*: PRope # module description
|
||||
deps*: PRope # dependencies
|
||||
id*: int # for generating IDs
|
||||
splitAfter*: int # split too long entries in the TOC
|
||||
tocPart*: seq[TTocEntry]
|
||||
@@ -765,9 +764,12 @@ proc getModuleFile(n: PNode): string =
|
||||
result = ""
|
||||
|
||||
proc traceDeps(d: PDoc, n: PNode) =
|
||||
if d.deps != nil: app(d.deps, ", ")
|
||||
app(d.deps, getModuleFile(n))
|
||||
|
||||
const k = skModule
|
||||
if d.section[k] != nil: app(d.section[k], ", ")
|
||||
dispA(d.section[k],
|
||||
"<a class=\"reference external\" href=\"$1.html\">$1</a>",
|
||||
"$1", [toRope(getModuleFile(n))])
|
||||
|
||||
proc generateDoc(d: PDoc, n: PNode) =
|
||||
if n == nil: return
|
||||
case n.kind
|
||||
@@ -802,8 +804,12 @@ proc generateDoc(d: PDoc, n: PNode) =
|
||||
else: nil
|
||||
|
||||
proc genSection(d: PDoc, kind: TSymKind) =
|
||||
const sectionNames: array[skModule..skTemplate, string] = [
|
||||
"Imports", "Types", "Consts", "Vars", "Procs", "Methods",
|
||||
"Iterators", "Converters", "Macros", "Templates"
|
||||
]
|
||||
if d.section[kind] == nil: return
|
||||
var title = toRope(copy($kind, 2) & 's')
|
||||
var title = toRope(sectionNames[kind])
|
||||
d.section[kind] = ropeFormatNamedVars(getConfigVar("doc.section"), [
|
||||
"sectionid", "sectionTitle", "sectionTitleID", "content"], [
|
||||
toRope(ord(kind)), title, toRope(ord(kind) + 50), d.section[kind]])
|
||||
@@ -833,14 +839,14 @@ proc genOutFile(d: PDoc): PRope =
|
||||
if d.hasToc: bodyname = "doc.body_toc"
|
||||
else: bodyname = "doc.body_no_toc"
|
||||
content = ropeFormatNamedVars(getConfigVar(bodyname), ["title",
|
||||
"tableofcontents", "moduledesc", "deps", "date", "time", "content"],
|
||||
[title, toc, d.modDesc, d.deps, toRope(getDateStr()),
|
||||
"tableofcontents", "moduledesc", "date", "time", "content"],
|
||||
[title, toc, d.modDesc, toRope(getDateStr()),
|
||||
toRope(getClockStr()), code])
|
||||
if optCompileOnly notin gGlobalOptions:
|
||||
code = ropeFormatNamedVars(getConfigVar("doc.file"), ["title",
|
||||
"tableofcontents", "moduledesc", "deps", "date", "time",
|
||||
"tableofcontents", "moduledesc", "date", "time",
|
||||
"content", "author", "version"],
|
||||
[title, toc, d.modDesc, d.deps, toRope(getDateStr()),
|
||||
[title, toc, d.modDesc, toRope(getDateStr()),
|
||||
toRope(getClockStr()), content, d.meta[metaAuthor],
|
||||
d.meta[metaVersion]])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user