@@ -78,6 +78,9 @@ def update_docs(pk, version_pk=None, build_pk=None, record=True, docker=False,
78
78
if vcs_results :
79
79
results .update (vcs_results )
80
80
81
+ if project .documentation_type == 'auto' :
82
+ update_documentation_type (version , api )
83
+
81
84
if docker or settings .DOCKER_ENABLE :
82
85
record_build (api = api , build = build , record = record , results = results , state = 'building' )
83
86
docker = DockerEnvironment (version )
@@ -139,6 +142,28 @@ def ensure_version(api, project, version_pk):
139
142
return version
140
143
141
144
145
+ def update_documentation_type (version , api ):
146
+ """
147
+ Automatically determine the doc type for a user.
148
+ """
149
+
150
+ checkout_path = version .project .checkout_path (version .slug )
151
+ os .chdir (checkout_path )
152
+ files = run ('find .' )[1 ].split ('\n ' )
153
+ markdown = sphinx = 0
154
+ for filename in files :
155
+ if fnmatch .fnmatch (filename , '*.md' ) or fnmatch .fnmatch (filename , '*.markdown' ):
156
+ markdown += 1
157
+ elif fnmatch .fnmatch (filename , '*.rst' ):
158
+ sphinx += 1
159
+ ret = 'sphinx'
160
+ if markdown > sphinx :
161
+ ret = 'mkdocs'
162
+ project_data = api .project (version .project .pk ).get ()
163
+ project_data ['documentation_type' ] = ret
164
+ api .project (version .project .pk ).put (project_data )
165
+ version .project .documentation_type = ret
166
+
142
167
def docker_build (version , pdf = True , man = True , epub = True , dash = True ,
143
168
search = True , force = False , intersphinx = True , localmedia = True ):
144
169
"""
0 commit comments