docgeni / docgeni

📖 A modern, powerful and out of the box documentation generator for Angular components lib and markdown docs.(现代化的、强大的、开箱即用的 Angular 组件文档生成工具)

Home Page:https://docgeni.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

无法加载多级目录文件,examples加载案例报错找不到组件或模块

kemaosen opened this issue · comments

commented

我的项目文件母料结构嵌套了多级,使用.docgenirc.js 对libs进行调整,但始终无法加载到多级目录下的doc目录下的文件

我的文件目录(使用docgeni-template)

├── kms - ui
│      ├── src
│      ├── project
│      │      ├── kms
│      │      │     ├──lib
│      │      │     │     ├──components
│      │      │     │     │     ├── button

我在.docgenirc.jslibs的配置

libs: [
    {
      name: 'kms',
      rootDir: './projects/kms',
      include: ['projects', 'projects/kms', 'projects/kms/lib', 'projects/kms/lib/components'],
    },
  ],

因为无法加载所以我页面展示的是一片空白.
问题:这是我修改配置有问题,还是暂不支持多级目录查找。

ps: 我反复测试了多次,应该不是我配置的问题,我按官方文档上的步骤在src下新建libbutton放在lib目录下没有任何问题,但再新建一级目录就无法加载了

commented

修正:目录写的是 project.docgenirc.js写的是projects,是创建问题时输入错误,他们是一样的使用的是projects

commented

浏览器控制台报错信息:

ERROR TypeError: Cannot read properties of undefined (reading 'toc')
    at SafeSubscriber._next (docgeni-template.js:3514:1)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:183:1)
    at SafeSubscriber.next (Subscriber.js:122:1)
    at Subscriber._next (Subscriber.js:72:1)
    at Subscriber.next (Subscriber.js:49:1)
    at TakeUntilSubscriber._next (Subscriber.js:72:1)
    at TakeUntilSubscriber.next (Subscriber.js:49:1)
    at CombineLatestSubscriber.notifyNext (combineLatest.js:73:1)
    at InnerSubscriber._next (InnerSubscriber.js:11:1)
    at InnerSubscriber.next (Subscriber.js:49:1)

Include 不用包含 rootDir

include lib/components

commented
commented

rootDir 需要相对于 cwd 根目录,也就是 package.json 目录

commented

多级使用include,相对于 rootDir 目录试试,应该可以

commented
commented

更新:切换写法后仍然不行,我昨天一直以为是libs出现了问题,我应该贴出报错信息
修改后的libs

libs: [
    {
      name: 'kms',
      rootDir: 'projects/kms',
      include: ['lib/components'],
    },
  ],

报错

1. If 'kms-top' is an Angular component, then verify that it is part of this module.
2. If 'kms-top' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

随后我反复查看文档,对比template项目。修改项目tsconfig.json文件。成功的将template改造成多级文件目录嵌套
到这里可以证明项目没有问题,我的代码有问题。
随后对比两个项目,仍然不行。我将template的下的文件直接cv过来仍然不行。
离谱,离离原上谱。
那么项目肯定没有问题,template中已经实现了是可行的。
我在tempalte项目中tsconfig.json 添加了一个新的alis

"paths": {
      "@docgeni/alib/*": [
        "src/*"
      ],
     "@kms":[ "src/*"]
    },

修改examples中module.ts中引用的别名,此时重新启动两边项目报同样的错误。
到此问题已经非常清晰了,可以说是关于tsconfig.json配置问题,单不全是
随后我又重新对比两边项目,发现template项目中.docgeni目录下有public目录,
public目录下还有tsconfig.json,这里的tsconfig.json中的paths并不是项目中我们后来定义的paths
嘿嘿!!!你不帮我改,我只能自己改了。修改完,npm run start:docs.
wuhu~~,使用@kms成功让项目跑起来并显示页面内容。
我重复上面的操作在另外一个项目中也成功了。
至此,结束。