MikhailKravets / mkdocs_puml

Inline PlantUML diagrams in your MkDocs documentation
MIT License
26 stars 5 forks source link

mkdocs_puml makes search unavailable #17

Closed astrizhachuk closed 1 year ago

astrizhachuk commented 1 year ago

mkdocs_puml works but makes search unavailable

Steps to reproduce the behavior:

  1. Create my-mkdocs-material docker image from squidfunk/mkdocs-material:latest with mkdocs_puml plugin
  2. Add to mkdocs.yml:
    plugins:
    - plantuml:
      puml_url: https://www.plantuml.com/plantuml/
      num_workers: 8
    - search:
      lang:
        - en
  3. Build site docker run --rm -it -p 8000:8000 -v "%cd%":/docs my-mkdocs-material build --verbose --strict --site-dir public
  4. Search unavailable: image

Without installed mkdocs_puml plugin: image

MikhailKravets commented 1 year ago

Hi @astrizhachuk! Thank you for reporting the issue 🤝. I'll take a look at it asap

MikhailKravets commented 1 year ago

@astrizhachuk, could you please share full mkdocs,.yml file? And what python version do you use?

astrizhachuk commented 1 year ago

@MikhailKravets python:3.11.0

mkdocs.yml:

site_name: ut_10_3

site_url: 'http://site/ut_10_3'
repo_name: 'dev1c/ut_10_3'
repo_url: 'https://site/dev1c/ut_10_3'
edit_uri: 'edit/master/-/docs'

theme: 
  name: material
  language: ru
  palette:
    # Dark mode
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: black
      accent: light blue
      toggle:
        icon: material/lightbulb
        name: Switch to light mode
    # Light mode
    - teal: "(prefers-color-scheme: light)"
      scheme: default
      primary: white
      accent: indigo
      toggle:
        icon: material/lightbulb-outline
        name: Switch to dark mode
  features:
    - content.code.annotate
    - navigation.tabs
    - search.highlight
    - toc.integrate
    - header.autohide
extra:
  social:
    - icon: fontawesome/brands/gitlab
      link: 'https://site/dev1c/ut_10_3'
extra_css:
  - 'assets/stylesheets/extra.css'
extra_javascript:
  - https://cdnjs.cloudflare.com/ajax/libs/tablesort/5.2.1/tablesort.min.js
  - assets/javascripts/tables.js
markdown_extensions:
  - admonition
  - abbr
  - attr_list
  - def_list
  - footnotes
  - meta
  - md_in_html
  - toc:
      permalink: true
  - pymdownx.arithmatex:
      generic: true
  - pymdownx.betterem:
      smart_enable: all
  - pymdownx.caret
  - pymdownx.details
  - pymdownx.emoji:
      emoji_index: !!python/name:materialx.emoji.twemoji
      emoji_generator: !!python/name:materialx.emoji.to_svg
  - pymdownx.highlight
  - pymdownx.inlinehilite
  - pymdownx.keys
  - pymdownx.magiclink:
      repo_url_shorthand: true
      user: squidfunk
      repo: mkdocs-material
  - pymdownx.mark
  - pymdownx.smartsymbols
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid-experimental
          format: !!python/name:pymdownx.superfences.fence_code_format
  - pymdownx.tabbed:
      alternate_style: true
  - pymdownx.tasklist:
      custom_checkbox: true
  - pymdownx.tilde
  - pymdownx.snippets

plugins:
  - plantuml:
      puml_url: https://www.plantuml.com/plantuml/
      num_workers: 8
  - search:
      lang:
        - ru
astrizhachuk commented 1 year ago

@MikhailKravets Dockerfile with plugin:

FROM python:3.11.0-alpine3.17

# Build-time flags
ARG WITH_PLUGINS=true

# Environment variables
ENV PACKAGES=/usr/local/lib/python3.11/site-packages
ENV PYTHONDONTWRITEBYTECODE=1

# Set build directory
WORKDIR /tmp

# Copy files necessary for build
COPY material material
COPY package.json package.json
COPY README.md README.md
COPY requirements.txt requirements.txt
COPY pyproject.toml pyproject.toml

# Perform build and cleanup artifacts and caches
RUN \
  apk upgrade --update-cache -a \
&& \
  apk add --no-cache \
    cairo \
    freetype-dev \
    git \
    git-fast-import \
    jpeg-dev \
    openssh \
    zlib-dev \
&& \
  apk add --no-cache --virtual .build \
    gcc \
    libffi-dev \
    musl-dev \
&& \
  pip install --no-cache-dir . \
&& \
  if [ "${WITH_PLUGINS}" = "true" ]; then \
    pip install --no-cache-dir \
      "mkdocs-minify-plugin>=0.3" \
      "mkdocs-redirects>=1.0" \
      "pillow>=9.0" \
      "cairosvg>=2.5" \
      "mkdocs_puml"; \
  fi \
&& \
  apk del .build \
&& \
  for theme in mkdocs readthedocs; do \
    rm -rf ${PACKAGES}/mkdocs/themes/$theme; \
    ln -s \
      ${PACKAGES}/material \
      ${PACKAGES}/mkdocs/themes/$theme; \
  done \
&& \
  rm -rf /tmp/* /root/.cache \
&& \
  find ${PACKAGES} \
    -type f \
    -path "*/__pycache__/*" \
    -exec rm -f {} \;

# Trust directory, required for git >= 2.35.2
RUN git config --global --add safe.directory /docs &&\
    git config --global --add safe.directory /site

# Set working directory
WORKDIR /docs

# Expose MkDocs development server port
EXPOSE 8000

# Start development server by default
ENTRYPOINT ["mkdocs"]
CMD ["serve", "--dev-addr=0.0.0.0:8000"]
astrizhachuk commented 1 year ago

If you add a plugin, then even without adding it to the plugins: section, the search does not work.

MikhailKravets commented 1 year ago

@astrizhachuk, I've run mkdocs server using python3.11 with and without docker. I couldn't recreate the problem. Please check if you install the latest packages to be used with python3.11.

Also, note that mkdocs serve command is development-only. For production, you should pre-build the web-site and then serve it with, for instance, nginx.

astrizhachuk commented 1 year ago

For example, I created docker-image w/plugin and a simple repository. Dockerfile and mkdocs.yml from my comments. Bug repeats.

git clone git@github.com:astrizhachuk/example-puml.git
cd example-puml
docker run --rm -it -p 8000:8000 -v "%cd%":/docs astrizhachuk/mkdocs-material-puml:latest build --verbose --strict --site-dir public
astrizhachuk commented 1 year ago

Diff for index.html (w/without plugin). <div class="md-search" is gone: image

MikhailKravets commented 1 year ago

Do the problem persist if you build or serve mkdocs outside the docker?

Just inside virtual env running the command

mkdocs serve

UPD. One more thing, do you use Windows or Linux / Mac?

astrizhachuk commented 1 year ago

Yep, problem persist outside the docker (ubuntu-20.04). When the plugin was installed in linux outside the docker:

> pip3 install mkdocs_puml
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
mkdocs-material 9.0.6 requires mkdocs>=1.4.2, but you have mkdocs 1.3.0 which is incompatible.
Successfully installed markdown-3.4.1 mkdocs-1.3.0

mkdocs only used in Gitlab Pages (ci/cd pipline, docker. linux):

pages:
  image: python:3.8-buster
  before_script:
    - pip install mkdocs
    - pip install mkdocs-material
    - pip install mkdocs_puml
  script:
    - mkdocs build --verbose --strict --site-dir public

Full pipline log: https://gist.github.com/astrizhachuk/5ccc80d5737167760e49dc77d2df4428

Dependency problem?

MikhailKravets commented 1 year ago

Yes! I've figured out the problem. Now I can recreate the bug. I'm already uploading the fix. For now, as a quick workaround, you can use mkdocs-material ~= 8 and mkdocs ~= 1.3.

Thanks for the support @astrizhachuk! Much appreciated 🚀

MikhailKravets commented 1 year ago

@astrizhachuk, please update mkdocs-puml package to the latest 1.1.0 version. Let me know if there is any other issue!