From bb349d60856a0a7776655d98e69aa6a620cb906c Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 23 Feb 2024 12:44:39 +0100 Subject: [PATCH] Update "make edoc" to use ExDoc --- .github/workflows/runtime.yml | 2 ++ Makefile.in | 26 ++++++++++++++++++++++---- mix.exs | 30 +++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index 5835fc3a7..f530f4c3a 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -341,6 +341,8 @@ jobs: - run: make xref + - run: make edoc + - name: Run rel run: | make rel diff --git a/Makefile.in b/Makefile.in index 98953ce4f..19d796955 100644 --- a/Makefile.in +++ b/Makefile.in @@ -133,6 +133,8 @@ ifeq "$(REBAR_VER)" "6" CONFIGURE_DEPS=(cd deps/eimp; ./configure) EBINDIR=$(DEPSDIR)/ejabberd/ebin XREFOPTIONS=graph + EDOCPRE=MIX_ENV=edoc + EDOCTASK=docs --proglang erlang CLEANARG=--deps ELIXIR_LIBDIR_RAW=$(shell elixir -e "IO.puts(:filename.dirname(:code.lib_dir(:elixir)))" -e ":erlang.halt") ELIXIR_LIBDIR=":$(ELIXIR_LIBDIR_RAW)" @@ -238,9 +240,25 @@ translations: doap: tools/generate-doap.sh -edoc: - $(ERL) -noinput +B -eval \ - 'case edoc:application(ejabberd, ".", []) of ok -> halt(0); error -> halt(1) end.' +#. +#' edoc +# + +edoc: edoc_files edoc_compile + $(EDOCPRE) $(REBAR) $(EDOCTASK) + +edoc_compile: deps + $(EDOCPRE) $(REBAR) compile + +edoc_files: _build/edoc/docs.md _build/edoc/logo.png + +_build/edoc/docs.md: edoc_compile + echo "For much more detailed and complete ejabberd documentation, " \ + "go to the [ejabberd Docs](https://docs.ejabberd.im/) site." \ + > _build/edoc/docs.md + +_build/edoc/logo.png: edoc_compile + wget https://docs.ejabberd.im/static/shared/images/footer_logo_e.png -O _build/edoc/logo.png #. #' copy-files @@ -650,7 +668,7 @@ help: @echo " relive Start a live ejabberd in _build/relive/" @echo "" @echo " doap Generate DOAP file" - @echo " edoc Generate edoc documentation (unused)" + @echo " edoc Generate EDoc documentation [mix]" @echo " options Generate ejabberd_option.erl" @echo " translations Extract translation files" @echo " TAGS Generate tags file for text editors" diff --git a/mix.exs b/mix.exs index 28fa171e8..631e0e728 100644 --- a/mix.exs +++ b/mix.exs @@ -3,6 +3,7 @@ defmodule Ejabberd.MixProject do def project do [app: :ejabberd, + source_url: "https://github.com/processone/ejabberd", version: version(), description: description(), elixir: elixir_required_version(), @@ -17,6 +18,7 @@ defmodule Ejabberd.MixProject do language: :erlang, releases: releases(), package: package(), + docs: docs(), deps: deps()] end @@ -103,7 +105,7 @@ defmodule Ejabberd.MixProject do [{:base64url, "~> 1.0"}, {:cache_tab, "~> 1.0"}, {:eimp, "~> 1.0"}, - {:ex_doc, ">= 0.0.0", only: :dev}, + {:ex_doc, "~> 0.31", only: [:dev, :edoc], runtime: false}, {:fast_tls, ">= 1.1.18"}, {:fast_xml, ">= 1.1.51"}, {:fast_yaml, "~> 1.0"}, @@ -161,6 +163,7 @@ defmodule Ejabberd.MixProject do for {:true, app} <- [{config(:pam), :epam}, {config(:lua), :luerl}, {config(:redis), :eredis}, + {Mix.env() == :edoc, :ex_doc}, {if_version_below(~c"22", true), :lager}, {config(:mysql), :p1_mysql}, {config(:sip), :esip}, @@ -350,6 +353,31 @@ defmodule Ejabberd.MixProject do release end + defp docs do + [ + main: "readme", + logo: "_build/edoc/logo.png", + source_ref: "master", + extra_section: "", # No need for Pages section name, it's the only one + api_reference: false, # API section has just Elixir, hide it + filter_modules: "aaaaa", # Module section has just Elixir modules, hide them + extras: [ + "README.md": [title: "Readme"], + "COMPILE.md": [title: "Compile and Install"], + "CONTAINER.md": [title: "Container Image"], + "CONTRIBUTING.md": [title: "Contributing"], + "CONTRIBUTORS.md": [title: "Contributors"], + "CODE_OF_CONDUCT.md": [title: "Code of Conduct"], + "CHANGELOG.md": [title: "ChangeLog"], + "COPYING": [title: "Copying License"], + "_build/edoc/docs.md": [title: "⟹ ejabberd Docs"] + ], + groups_for_extras: [ + "": Path.wildcard("*.md") ++ ["COPYING"], + "For more documentation": "_build/edoc/docs.md" + ] + ] + end end defmodule Mix.Tasks.Compile.Asn1 do