Skip to content

Commit

Permalink
Generate hidden chunk files for any internal modules
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Feb 24, 2020
1 parent 1cd2aac commit d58966b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions lib/erl_docgen/priv/bin/chunk.escript
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@

-include_lib("kernel/include/eep48.hrl").

main([FromBeam, _Escript, ToChunk]) ->
%% This module is not documented, generate an empty beam chunk file
Name = filename:basename(filename:rootname(FromBeam)) ++ ".erl",

EmptyDocs = #docs_v1{ anno = erl_anno:set_file(Name, erl_anno:new(0)),
module_doc = hidden, docs = []},
file:write_file(ToChunk, term_to_binary(EmptyDocs,[compressed])),
ok;
main([FromXML, FromBeam, _Escript, ToChunk]) ->
erlang:process_flag(max_heap_size,20 * 1000 * 1000),
case docs(FromXML, FromBeam) of
Expand Down
4 changes: 3 additions & 1 deletion lib/stdlib/src/shell_docs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ get_local_doc(_Missing, ModuleDoc) when map_size(ModuleDoc) > 0 ->
%% Otherwise take first alternative found
binary_to_term(maps:get(hd(maps:keys(ModuleDoc)), ModuleDoc));
get_local_doc(Missing, hidden) ->
[{p,[],[<<"The documentation for ">>,Missing,<<" is hidden">>]}];
[{p,[],[<<"The documentation for ">>,Missing,
<<" is hidden. This probably means that it is internal "
"and not to be used by other applications.">>]}];
get_local_doc(Missing, None) when None =:= none; None =:= #{} ->
[{p,[],[<<"There is no documentation for ">>,Missing]}].

Expand Down
2 changes: 1 addition & 1 deletion lib/wx/doc/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ TOP_SPECS_FILE = specs.xml

include $(ERL_TOP)/make/doc.mk

$(XMLDIR)/%.xml: $(APP_DIR)/gen/%.erl
$(XMLDIR)/%.xml: $(APP_SRC_DIR)/gen/%.erl
$(gen_verbose)escript $(DOCGEN)/priv/bin/xml_from_edoc.escript \
-def vsn $(VSN) $(EDOC_FLAGS) -dir $(XMLDIR) $<

Expand Down
13 changes: 9 additions & 4 deletions make/doc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ RELSYSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN)
endif
RELCHUNKSDIR = $(RELEASE_PATH)/lib/$(APPLICATION)-$(VSN)

APP_DIR = $(ERL_TOP)/lib/$(APPLICATION)/src
APP_DIR = $(ERL_TOP)/lib/$(APPLICATION)
APP_SRC_DIR = $(APP_DIR)/src
APP_EBIN_DIR = $(APP_DIR)/src

# ----------------------------------------------------
HTML_FILES = $(XML_APPLICATION_FILES:%.xml=$(HTMLDIR)/%.html) \
Expand Down Expand Up @@ -63,6 +65,9 @@ endif
CHUNK_REF3_FILES = $(filter-out $(NO_CHUNKS), $(XML_ALL_REF3_FILES))
CHUNK_FILES = $(CHUNK_REF3_FILES:%.xml=$(CHUNKSDIR)/%.chunk)

ERL_CHUNK_FILES = $(patsubst $(APP_EBIN_DIR)/%.BEAM,$(CHUNKSDIR)/%.chunk,$(wildcard $(APP_EBIN_DIR)/*.beam))
EMPTY_CHUNK_FILES = $(filter-out $(NO_CHUNKS:%.xml=$(CHUNKSDIR)/%.chunk) $(CHUNK_FILES), $(ERL_CHUNK_FILES))


# ----------------------------------------------------
# FLAGS
Expand Down Expand Up @@ -90,13 +95,13 @@ html: images $(HTML_REF_MAN_FILE)

man: $(MAN1_FILES) $(MAN2_FILES) $(MAN3_FILES) $(MAN4_FILES) $(MAN5_FILES) $(MAN6_FILES) $(MAN7_FILES)

chunks: $(CHUNK_FILES)
chunks: $(CHUNK_FILES) $(EMPTY_CHUNK_FILES)

images: $(IMAGE_FILES:%=$(HTMLDIR)/%)

$(EDOC_REF3_FILES:%=$(XMLDIR)/%): $(APP_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
$(EDOC_REF3_FILES:%=$(XMLDIR)/%): $(APP_SRC_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
$(gen_verbose)escript $(DOCGEN)/priv/bin/xml_from_edoc.escript \
-def vsn $(VSN) $(EDOC_FLAGS) -dir $(XMLDIR) $(APP_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
-def vsn $(VSN) $(EDOC_FLAGS) -dir $(XMLDIR) $(APP_SRC_DIR)/$(@:$(XMLDIR)/%.xml=%.erl)
$(XMLDIR)/$(EDOC_CHAPTER_FILE): ../overview.edoc
$(gen_verbose)escript $(DOCGEN)/priv/bin/xml_from_edoc.escript -def vsn $(VSN) \
-chapter -dir $(XMLDIR) $<
Expand Down
3 changes: 3 additions & 0 deletions make/otp.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,6 @@ $(CHUNKSDIR)/%.chunk: $(XMLDIR)/%.xml ../../ebin/%.beam $(DOCGEN)/priv/bin/chunk

$(CHUNKSDIR)/%.chunk: $(XMLDIR)/%.xml ../../preloaded/ebin/%.beam $(DOCGEN)/priv/bin/chunk.escript
$(gen_verbose)escript $(DOCGEN)/priv/bin/chunk.escript $^ $@

$(CHUNKSDIR)/%.chunk: ../../ebin/%.beam $(DOCGEN)/priv/bin/chunk.escript
$(gen_verbose)escript $(DOCGEN)/priv/bin/chunk.escript $^ $@

0 comments on commit d58966b

Please sign in to comment.