question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Techdocs] README.md index page fallback does not work during `techdocs-cli generate` without `--techdocs-ref`

See original GitHub issue

Relates to #7080. Relates to #6057.

The feature implemented in #7080 provides a fallback to a README.md file in case docs/index.md is not found. This doesn’t appear to work when generating docs in a CI/CD pipeline with the techdocs-cli generate command.

Expected Behavior

Docs generation should attempt to use a README.md in the source directory in case docs/index.md is not found.

Current Behavior

Docs generation is not using theREADME.md in the source directory when docs/index.md is not found.

Workaround

After some debugging, I found that providing a bogus value to the --techdocs-ref argument when generating from the root of my repository was enough to get the feature working:

# Fallback is not invoked
npx @techdocs/cli generate --no-docker -v

# Fallback works when providing a --techdocs-ref argument
npx @techdocs/cli generate --no-docker -v --techdocs-ref .

This seems to be because the patchIndexPreBuild method that provides the README.md fallback in techdocs-common is gated by the presence of a non-empty --techdocs-ref argument (represented by the parsedLocationAnnotation option): https://github.com/backstage/backstage/blob/986a5d869ea976fee71844c2aadd777907fde082/packages/techdocs-common/src/stages/generate/techdocs.ts#L95-L103

Possible Solution

I can’t see why patchIndexPreBuild needs to be called from within the conditional block. If it sounds like a reasonable path forward, I can PR a change that moves it outside so that it happens regardless of if a --techdocs-ref argument is provided during generation.

Your Environment

  • techdocs version: latest (using npx for invocation)
  • NodeJS Version: v16.13.10
  • Operating System and Version: MacOS Big Sur 11.6

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ngeegohcommented, Jan 24, 2022

Hi @ctrombley ,

I have the same issue but thanks to your workaround I can get it generated now. However, I have a question, when Backstage displays readme.md contents in techdocs, all the images attached to README.md cant be rendered and displayed. It looks like this image Do you know whats the fix for this? or Backstage techdocs just cannot display images? (FYI: techdocs generates and publishs techdocs files to Azure storage account)

0reactions
soaprajcommented, Jun 30, 2022

Closing this issue for now. Please feel free to reopen if you have more inputs on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting TechDocs - Backstage.io
Using the TechDocs CLI, you can troubleshoot MkDocs build issues locally. Note this requires you have Docker available to launch images.
Read more >
Using TechDocs - Roadie.io
Inside that directory, create a file called index.md with some markdown content inside. No frontmatter is required.
Read more >
The TechDocs Beta has landed - Spotify Backstage
Leading up to the beta release, we worked to surface and improve relevant errors and other details during the documentation generation process.
Read more >
@techdocs/cli - npm
You are of course also free to create your own local test site - all it takes is a docs/index.md and an mkdocs.yml...
Read more >
@backstage/plugin-scaffolder: Versions | Openbase
As an example, if you are using GitHubIssuesPage from the GitHub Issues ... The default Techdocs behavior will no longer attempt to copy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found