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

🌐 Fix live docs server for translations for some languages #4729

Merged
merged 5 commits into from May 10, 2022

Conversation

wakabame
Copy link
Contributor

Docs for tests fail in some languages due to undefined 'sponsors' (fr, ja, zh) or no docs/ in dir(az):

`python ./scripts/docs.py live ja`
$ python ./scripts/docs.py live ja
ERROR:mkdocs.commands.build:Error reading page 'fastapi-people.md': 'sponsors' is undefined
Traceback (most recent call last):
  File "./scripts/docs.py", line 449, in <module>
    app()
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "./scripts/docs.py", line 357, in live
    mkdocs.commands.serve.serve(dev_addr="127.0.0.1:8008")
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 54, in serve
    config = builder()
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 49, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/mkdocs/commands/build.py", line 170, in _populate_page
    page.markdown = config['plugins'].run_event(
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/markdownextradata/plugin.py", line 99, in on_page_markdown
    return self.apply_template(markdown)
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/markdownextradata/plugin.py", line 111, in apply_template
    return md_template.render({**self.mkdocsConfig, **self.mkdocsConfig.get("extra")})
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 118, in top-level template code
  File "/home/wakabame/fastapi/env/lib/python3.8/site-packages/jinja2/environment.py", line 474, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'sponsors' is undefined
`python ./scripts/docs.py live az`
$ python ./scripts/docs.py live az
ERROR:mkdocs.config:Config value: 'docs_dir'. Error: The path /home/wakabame/fastapi/docs/az/docs isn't an existing directory.
Aborted with 1 Configuration Errors!
  • Since the sponsor is not defined in the development environment, we need check {% if sponsors %} before {% if sponsors.gold %}.
  • In docs/az/docs, temporarily create .gitkeep to make the directory aware

@codecov
Copy link

codecov bot commented Apr 27, 2022

Codecov Report

Merging #4729 (e24d50f) into master (0d1be46) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master     #4729   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          531       531           
  Lines        13629     13629           
=========================================
  Hits         13629     13629           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d1be46...e24d50f. Read the comment docs.

@github-actions
Copy link
Contributor

📝 Docs preview for commit 53bd7a9 at: https://62692b82115c23170382e0c6--fastapi.netlify.app

@tiangolo tiangolo changed the title 🌐 Fixed a bug that occurred when running live server for docs in some languages. 🌐 Fix live docs server for translations for some languages May 10, 2022
@tiangolo tiangolo enabled auto-merge (squash) May 10, 2022 00:25
@tiangolo tiangolo merged commit e5980a7 into tiangolo:master May 10, 2022
@tiangolo
Copy link
Owner

Good catch, thank you @wakabame ! 🚀

@wakabame
Copy link
Contributor Author

@tiangolo
Thank you for your review and acceptance!

@wakabame wakabame deleted the docs-live-build branch May 10, 2022 00:56
JeanArhancet pushed a commit to JeanArhancet/fastapi that referenced this pull request Aug 20, 2022
…4729)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants