 : scaffolding ( path -- )
     "Creating scaffolding for " write <pathname> . ;
 
+: (scaffold-path) ( path string -- path )
+    dupd [ file-name ] dip append append-path ;
+
 : scaffold-path ( path string -- path ? )
-    dupd [ file-name ] dip append append-path
+    (scaffold-path)
     dup exists? [ dup not-scaffolding f ] [ dup scaffolding t ] if ;
 
 : scaffold-copyright ( -- )


: check-vocab ( vocab -- vocab )
    dup find-vocab-root [ no-vocab ] unless ;
PRIVATE>

: link-vocab ( vocab -- )
    check-vocab
    "Edit documentation: " write
    [ find-vocab-root ] keep
    [ append-path ] keep "-docs.factor" append append-path
    <pathname> . ;

: help. ( word -- )
    [ (help.) ] [ nl vocabulary>> link-vocab ] bi ;

ERROR: no-vocab vocab ;

<PRIVATE

: root? ( string -- ? ) vocab-roots get member?  ;

: length-changes? ( seq quot -- ? )
    dupd call [ length ] bi@ = not ; inline

: check-vocab-name ( string -- string )
    dup [ [ CHAR: . = ] trim ] length-changes?
    [ vocab-name-contains-dot ] when

    ".." over subseq? [ vocab-name-contains-dot ] when

    dup [ path-separator? ] contains?
    [ vocab-name-contains-separator ] when ;

