Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all non-documentation comments to documentation #180

Closed
haxscramper opened this issue Jan 19, 2022 · 0 comments · Fixed by #189
Closed

Convert all non-documentation comments to documentation #180

haxscramper opened this issue Jan 19, 2022 · 0 comments · Fixed by #189
Labels
good first issue Easy-to-start-with issue with no in-depth knowledge or complex implementation required. refactor Implementation refactor

Comments

@haxscramper
Copy link
Collaborator

haxscramper commented Jan 19, 2022

Most of the compiler modules use single comment for documentation of the different procedures, fields, toplevel modules and so on. They won't show up in the generated documentation for modules.

type
  Ctx = object
    g: ModuleGraph
    fn: PSym
    stateVarSym: PSym # :state variable. nil if env already introduced by lambdalifting
    tmpResultSym: PSym # Used when we return, but finally has to interfere
    unrollFinallySym: PSym # Indicates that we're unrolling finally states (either exception happened or premature return)
    curExcSym: PSym # Current exception

    states: seq[PNode] # The resulting states. Every state is an nkState node.
    blockLevel: int # Temp used to transform break and continue stmts
    stateLoopLabel: PSym # Label to break on, when jumping between states.
    exitStateIdx: int # index of the last state
    tempVarId: int # unique name counter
    tempVars: PNode # Temp var decls, nkVarSection
    exceptionTable: seq[int] # For state `i` jump to state `exceptionTable[i]` if exception is raised
    hasExceptions: bool # Does closure have yield in try?
    curExcHandlingState: int # Negative for except, positive for finally
    nearestFinally: int # Index of the nearest finally block. For try/except it
                    # is their finally. For finally it is parent finally. Otherwise -1
    idgen: IdGenerator

Convert comments like these into documentation ones where applicable (not every single comment is actually a documentation, sometimes they are TODO etc.)

This also applies to the discard """ comments.

discard """

one major problem:
  spawn f(a[i])
  inc i
  spawn f(a[i])
is valid, but
  spawn f(a[i])
  spawn f(a[i])
  inc i
is not! However,
  spawn f(a[i])
  if guard: inc i
  spawn f(a[i])
is not valid either! --> We need a flow dependent analysis here.

However:
  while foo:
    spawn f(a[i])
    inc i
    spawn f(a[i])

Is not valid either! --> We should really restrict 'inc' to loop endings?

The heuristic that we implement here (that has no false positives) is: Usage
of 'i' in a slice *after* we determined the stride is invalid!
"""
@haxscramper haxscramper added good first issue Easy-to-start-with issue with no in-depth knowledge or complex implementation required. refactor Implementation refactor labels Jan 19, 2022
haxscramper added a commit to haxscramper/nimskull that referenced this issue Jan 21, 2022
Reformat comments to use double hash (to make them visible in
documentation), add readme.rst in compiler subsystem directories.

Mostly closes nim-works#180 although
there might be some bits and pieces that can be formatted better.
bors bot added a commit that referenced this issue Jan 22, 2022
189: doc: reformat comments, add readmes in subdirs r=saem a=haxscramper

Reformat comments to use double hash (to make them visible in
documentation), add readme.rst in compiler subsystem directories.

Mostly closes #180 although
there might be some bits and pieces that can be formatted better.


Co-authored-by: haxscramper <haxscramper@gmail.com>
@bors bors bot closed this as completed in 41a7cef Jan 22, 2022
tandy-1000 pushed a commit to tandy-1000/nimskull that referenced this issue Jan 24, 2022
Reformat comments to use double hash (to make them visible in
documentation), add readme.rst in compiler subsystem directories.

Mostly closes nim-works#180 although
there might be some bits and pieces that can be formatted better.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Easy-to-start-with issue with no in-depth knowledge or complex implementation required. refactor Implementation refactor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant