docgen: module dependencies are now listed

This commit is contained in:
Araq 2011-01-16 14:30:31 +01:00
commit 07b784373b
7 changed files with 55 additions and 37 deletions

View file

@ -45,16 +45,12 @@ doc.body_toc = """
$tableofcontents $tableofcontents
<div class="content" id="content"> <div class="content" id="content">
$moduledesc $moduledesc
<h1>Dependencies</h1>
$deps
$content $content
</div> </div>
""" """
doc.body_no_toc = """ doc.body_no_toc = """
$moduledesc $moduledesc
<h1>Dependencies</h1>
$deps
$content $content
""" """

View file

@ -30,17 +30,11 @@ doc.toc = r"\tableofcontents \newpage"
doc.body_toc = """ doc.body_toc = """
$tableofcontents $tableofcontents
$moduledesc $moduledesc
Dependencies: $deps
$content $content
""" """
doc.body_no_toc = """ doc.body_no_toc = """
$moduledesc $moduledesc
Dependencies: $deps
$content $content
""" """

View file

@ -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 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. 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 DLL generation
============== ==============
Nimrod supports the generation of DLLs. However, there must be only one 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 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:: on ``nimrtl.dll``. To generate the "nimrtl.dll" file, use the command::
nimrod c -d:release lib/nimrtl.nim nimrod c -d:release lib/nimrtl.nim

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod's Runtime Library # Nimrod's Runtime Library
# (c) Copyright 2010 Andreas Rumpf # (c) Copyright 2011 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -19,11 +19,11 @@
## Coding conventions: ## Coding conventions:
## ALL types are named the same as in the POSIX standard except that they start ## 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 ## consistent with Nimrod conventions. If an identifier is a Nimrod keyword
## the \`identifier\` notation is used. ## 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 ## resulting C code will just include <XYZ.h> and *not* define the
## symbols declared here. ## symbols declared here.

View file

@ -1,7 +1,7 @@
# #
# #
# Nimrod's Runtime Library # Nimrod's Runtime Library
# (c) Copyright 2010 Andreas Rumpf # (c) Copyright 2011 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.
@ -69,7 +69,21 @@ when defined(Windows):
dwCreationFlags: int32, lpThreadId: var int32): THandle {. dwCreationFlags: int32, lpThreadId: var int32): THandle {.
stdcall, dynlib: "kernel32", importc: "CreateThread".} 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: else:
type type
TSysLock {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int TSysLock {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int
@ -81,23 +95,20 @@ else:
importc: "pthread_mutex_lock", header: "<pthread.h>".} importc: "pthread_mutex_lock", header: "<pthread.h>".}
proc Release(L: var TSysLock) {. proc Release(L: var TSysLock) {.
importc: "pthread_mutex_unlock", header: "<pthread.h>".} 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 type
TThread* = TSysThread TThread* = TSysThread
TLock* = TSysLock TLock* = TSysLock
TThreadFunc* = proc (closure: pointer) {.cdecl.} 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) = proc createThread*(t: var TThread, fn: TThreadFunc, closure: pointer) =
when defined(windows): when defined(windows):
nil nil

View file

@ -280,6 +280,7 @@ type
skParam, # a parameter skParam, # a parameter
skGenericParam, # a generic parameter; eq in ``proc x[eq=`==`]()`` skGenericParam, # a generic parameter; eq in ``proc x[eq=`==`]()``
skTemp, # a temporary variable (introduced by compiler) skTemp, # a temporary variable (introduced by compiler)
skModule, # module identifier
skType, # a type skType, # a type
skConst, # a constant skConst, # a constant
skVar, # a variable skVar, # a variable
@ -293,7 +294,6 @@ type
skField, # a field in a record or object skField, # a field in a record or object
skEnumField, # an identifier in an enum skEnumField, # an identifier in an enum
skForVar, # a for loop variable skForVar, # a for loop variable
skModule, # module identifier
skLabel, # a label (for block statement) skLabel, # a label (for block statement)
skStub # symbol is a stub and not yet loaded from the ROD skStub # symbol is a stub and not yet loaded from the ROD
# file (it is loaded on demand, which may mean: never) # file (it is loaded on demand, which may mean: never)

View file

@ -32,7 +32,6 @@ type
filename*: string # filename of the source file; without extension filename*: string # filename of the source file; without extension
basedir*: string # base directory (where to put the documentation) basedir*: string # base directory (where to put the documentation)
modDesc*: PRope # module description modDesc*: PRope # module description
deps*: PRope # dependencies
id*: int # for generating IDs id*: int # for generating IDs
splitAfter*: int # split too long entries in the TOC splitAfter*: int # split too long entries in the TOC
tocPart*: seq[TTocEntry] tocPart*: seq[TTocEntry]
@ -765,9 +764,12 @@ proc getModuleFile(n: PNode): string =
result = "" result = ""
proc traceDeps(d: PDoc, n: PNode) = proc traceDeps(d: PDoc, n: PNode) =
if d.deps != nil: app(d.deps, ", ") const k = skModule
app(d.deps, getModuleFile(n)) 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) = proc generateDoc(d: PDoc, n: PNode) =
if n == nil: return if n == nil: return
case n.kind case n.kind
@ -802,8 +804,12 @@ proc generateDoc(d: PDoc, n: PNode) =
else: nil else: nil
proc genSection(d: PDoc, kind: TSymKind) = 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 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"), [ d.section[kind] = ropeFormatNamedVars(getConfigVar("doc.section"), [
"sectionid", "sectionTitle", "sectionTitleID", "content"], [ "sectionid", "sectionTitle", "sectionTitleID", "content"], [
toRope(ord(kind)), title, toRope(ord(kind) + 50), d.section[kind]]) 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" if d.hasToc: bodyname = "doc.body_toc"
else: bodyname = "doc.body_no_toc" else: bodyname = "doc.body_no_toc"
content = ropeFormatNamedVars(getConfigVar(bodyname), ["title", content = ropeFormatNamedVars(getConfigVar(bodyname), ["title",
"tableofcontents", "moduledesc", "deps", "date", "time", "content"], "tableofcontents", "moduledesc", "date", "time", "content"],
[title, toc, d.modDesc, d.deps, toRope(getDateStr()), [title, toc, d.modDesc, toRope(getDateStr()),
toRope(getClockStr()), code]) toRope(getClockStr()), code])
if optCompileOnly notin gGlobalOptions: if optCompileOnly notin gGlobalOptions:
code = ropeFormatNamedVars(getConfigVar("doc.file"), ["title", code = ropeFormatNamedVars(getConfigVar("doc.file"), ["title",
"tableofcontents", "moduledesc", "deps", "date", "time", "tableofcontents", "moduledesc", "date", "time",
"content", "author", "version"], "content", "author", "version"],
[title, toc, d.modDesc, d.deps, toRope(getDateStr()), [title, toc, d.modDesc, toRope(getDateStr()),
toRope(getClockStr()), content, d.meta[metaAuthor], toRope(getClockStr()), content, d.meta[metaAuthor],
d.meta[metaVersion]]) d.meta[metaVersion]])
else: else: